rohs英语怎么念:急~~高手进!!

来源:百度文库 编辑:神马品牌网 时间:2024/05/12 01:42:55
帮忙找错误!
#include<stdio.h>
#include<conio.h>
#include<stdlib.h>

struct list
{
int sno;
int age;
int score;
struct list * next;
};
typedef struct list node ;
node * creat();
node * find(node *);
node * insertlist(node *);
node * deletelist(node *);

int main()
{
node * head,* tail1,* tail2,tail3,* p;
int a;
head = creat();
scanf("%d", &a);
if(a==1)
{
tail1 = find(head);
for(p = tail1;p!=NULL;p = p->next)
printf("%d %d %f", tail1->sno,tail1->age,tail1->score);
}
else if(a==2)
{
tail2 = insertlist(head);
for(p = tail2->next;p->next!=NULL;p = p->next)
printf("%d %d %f ", p->sno,p->age,p->score);
}
else if(a==3)
{
tail3 = deletelist(head);
for(p = tail3->next;p!=NULL;p = p->next)
printf("%d %d %f", p->sno,p->age,p->score);
}
else
printf('YOU ARY ERROR') ;
getch();
return 0;
}

node * creat()
{
node * head,* p,*q,* tail;
int a,b,c;
head = (node *)malloc(sizeof (node));
head->next = NULL;

scanf("%d%d%f", &a,&b,&c);
q = (node *)malloc(sizeof (node));
q->sno = a;
q->age = b;
q->score = c;
q->next = NULL;
head->next = q;
scanf("%d%d%d", &a,&b,&c);
while(a!=0)
{
p = (node *)malloc(sizeof (node));
p->sno = a;
p->age = b;
p->score = c;
for(tail = head;tail->next!=NULL;tail = tail->next)
{
if(p->score < tail->next->score)
{
tail->next = p;
p->next = tail->next;
}
}
tail->next = p;
p->next = NULL;
scanf("%d%d%d", &a,&b,&c);
}
return head;
}

node * find(node * head)
{
node * p;
int n;
scanf("%d", &n);
for(p = head->next;p!=NULL;p = p->next)
if(p->sno == n)
break ;
return p;
}

node * insertlist(node * head)
{
node * p,* tail;
int a,b,c;
scanf("%d%d%f", &a,&b,&c);
p = (node *)malloc(sizeof (node));
p->sno = a;
p->age = b;
p->score = c;
p->next = NULL;
for(tail = head;tail->next!=NULL;tail = tail->next)
{
if(p->score < tail->next->score)
{
tail->next = p;
p->next = tail->next;
}
}
tail->next = p;
return head;
}

node * deletelist(node * head)
{
node * p;
int n;
scanf("%d", &n);
for(p = head->next;p = !NULL;p = p->next)
{
if(n==p->next->sno)
{
p->next = p->next->next;

}
}
return head;
}

//注释为你原来的语句

#include<stdio.h>
#include<conio.h>
#include<stdlib.h>

struct list
{
int sno;
int age;
int score;
struct list * next;
};
typedef struct list node ;
node * creat();
node * find(node *);
node * insertlist(node *);
node * deletelist(node *);

int main()
{
node * head,* tail1,* tail2,* tail3,* p; //tail2
int a;
head = creat();
scanf("%d", &a);
if(a==1)
{
tail1 = find(head);
for(p = tail1;p!=NULL;p = p->next)
printf("%d %d %f", tail1->sno,tail1->age,tail1->score);
}
else if(a==2)
{
tail2 = insertlist(head);
for(p = tail2->next;p->next!=NULL;p = p->next)
printf("%d %d %f ", p->sno,p->age,p->score);
}
else if(a==3)
{
tail3 = deletelist(head);
for(p = tail3->next;p!=NULL;p = p->next)
printf("%d %d %f", p->sno,p->age,p->score);
}
else
printf("YOU ARY ERROR") ; //printf('YOU ARY ERROR') ;
getch();
return 0;
}

node * creat()
{
node * head,* p,*q,* tail;
int a,b,c;
head = (node *)malloc(sizeof (node));
head->next = NULL;

scanf("%d%d%f", &a,&b,&c);
q = (node *)malloc(sizeof (node));
q->sno = a;
q->age = b;
q->score = c;
q->next = NULL;
head->next = q;
scanf("%d%d%d", &a,&b,&c);
while(a!=0)
{
p = (node *)malloc(sizeof (node));
p->sno = a;
p->age = b;
p->score = c;
for(tail = head;tail->next!=NULL;tail = tail->next)
{
if(p->score < tail->next->score)
{
tail->next = p;
p->next = tail->next;
}
}
tail->next = p;
p->next = NULL;
scanf("%d%d%d", &a,&b,&c);
}
return head;
}

node * find(node * head)
{
node * p;
int n;
scanf("%d", &n);
for(p = head->next;p!=NULL;p = p->next)
if(p->sno == n)
break ;
return p;
}

node * insertlist(node * head)
{
node * p,* tail;
int a,b,c;
scanf("%d%d%f", &a,&b,&c);
p = (node *)malloc(sizeof (node));
p->sno = a;
p->age = b;
p->score = c;
p->next = NULL;
for(tail = head;tail->next!=NULL;tail = tail->next)
{
if(p->score < tail->next->score)
{
tail->next = p;
p->next = tail->next;
}
}
tail->next = p;
return head;
}

node * deletelist(node * head)
{
node * p;
int n;
scanf("%d", &n);
for(p = head->next;p = !NULL;p = p->next)
{
if(n==p->next->sno)
{
p->next = p->next->next;

}
}
return head;
}