70,026
社区成员




#include <stdio.h>
#include <stdlib.h>
#include <malloc.h>
#define scanf scanf_s
struct student {
char name[20];
int age;
struct student *next;
};
struct student *creat(){
struct student *h,*p1,*p2;
static int n;
h=NULL;
p1=p2=(struct student *)malloc(sizeof(struct student));
scanf("%s%d",p1->name,p1->age);
while (p1->name!=0){
n++;
if (n==1)
h=p1;
else
p2->next=p1;
p2=p1;
p1=(struct student *)malloc(sizeof(struct student));
scanf("%s%d",p1->name,p1->age);
}
p2->next=NULL;
return h;
}
void main(){
struct student *creat();
struct student *head,*p;
head=creat();
p=head;
while(p){
printf("%s,%d",p->name,p->age);
p=p->next;
}
}
#include <time.h>
#include <stdlib.h>
#include <windows.h>
int main() {
int a,b[11];//本来是b[10],为判断哪句越界,故意声明为b[11]
srand((unsigned int)time(NULL));//按两次F11,等黄色右箭头指向本行时,调试、新建断点、新建数据断点,地址:&b[10],字节计数:4,确定。
while (1) {//按F5,会停在下面某句,此时a的值为10,b[10]已经被修改为对应0..4之一。
b[(a=rand()%11)]=0;
Sleep(100);
b[(a=rand()%11)]=1;
Sleep(100);
b[(a=rand()%11)]=2;
Sleep(100);
b[(a=rand()%11)]=3;
Sleep(100);
b[(a=rand()%11)]=4;
Sleep(100);
}
return 0;
}
#include <stdio.h>
#include <stdlib.h>
#include <malloc.h>
struct student {
char name[20];
int age;
struct student *next;
};
struct student *creat(){
struct student *h,*p1,*p2;
static int n;
h=NULL;
p1=p2=(struct student *)malloc(sizeof(struct student));
printf("输入# 1结束\n");
scanf("%s %d",p1->name,&p1->age);
while (p1->name[0]!='#'){
n++;
if (n==1)
h=p1;
else
p2->next=p1;
p2=p1;
p1=(struct student *)malloc(sizeof(struct student));
scanf("%s %d",p1->name,&p1->age);
}
p2->next=NULL;
return h;
}
void main(){
struct student *creat();
struct student *head,*p;
head=creat();
p=head;
while(p){
printf("%s,%d\n",p->name,p->age);
p=p->next;
}
}
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <malloc.h>
//#define scanf scanf_s
struct student {
char name[20];
int age;
struct student *next;
};
struct student *creat();
void main(){
struct student *head,*p;
head = creat();
p = head;
while(p){
printf("%s,%d\n",p->name,p->age);
p = p->next;
}
return;
}
struct student *creat(){
struct student *h, *p1, *p2;
static int n;
h = NULL;
p1 = p2 = (struct student *)malloc(sizeof(struct student));
scanf("%s%d", p1->name, &p1->age);
while(strcmp(p1->name, "q") != 0){
n++;
if(n == 1)
h = p1;
else
p2->next = p1;
p2 = p1;
p1 = (struct student *)malloc(sizeof(struct student));
scanf("%s%d", p1->name, &p1->age);
}
p2->next=NULL;
return h;
}