- 注册时间
- 2007-7-14
- 最后登录
- 1970-1-1
|
- struct student
- {
- int num;
- char name[20];
- char sex;
- float hight;
- float weight;
- struct student *next;
- };
- void Add(struct student *head,int *n)
- {
- int *m=n;
- int number;
- struct student *p1,*p2,*p0;
- if(head==0)
- {
- head=(struct student *)malloc(sizeof(struct student));
- if(!head)
- {
- printf("\nError");
- return;
- }
- else
- {
- printf("\nSet Success");
- *m=*m+1;
- }
- }
- p1=p2=head;
- printf("\ninput plus number:\n");
- scanf("%d",&number);
- for(int i=0;i<*m;i++)
- {
- p1=p2;
- p2=p1->next;
- if(p1->num==number||p2->num==number)
- {
- printf("\nSorry!have it now");
- break;
- }
- else if(p1->num<number&&p2->num>number)
- {
- p1->next=p0=(struct student *)malloc(sizeof(struct student));
- scanf("%d %s %c %f %f",p1);
- printf("\nRealy?(Y/N)");
- char key=getchar();
- if(key=='y')
- {
- p0->next=p2;
- }
- }
- }
- }
复制代码 这一段调试时没有错,就是运行不起来 |
|