C语言编程,有一个错误,帮忙改正一下。谢谢!

[复制链接]
查看11 | 回复2 | 2011-5-6 11:47:59 | 显示全部楼层 |阅读模式
#include
#include
#include
struct students{
int number;
char name[20];
int score;
struct students * next;
};
int main(void)
{
struct students * head , * tail , * p;
head = tail = NULL;

int num , score;
int number;
int size = sizeof(struct students);
char name[20];
scanf("%d" ,&num);
while(num != 0)
{
p = (struct students *) malloc (size);
scanf("%s%d", name , &score);
p -> number = num;
strcpy(p -> name , name);
p -> score = score;
p -> next = NULL;
if(head == NULL)
head = p;
else
tail -> next = p;
tail = p;
scanf("%d" ,&num);
}
scanf("%d", &number);

for(p = head; p ;p = p -> next)
{
if((p -> score) >= number)
printf("%d\t%s\t%d\n", p -> number ,p -> name,p -> score);
}
return 0;
}

回复

使用道具 举报

千问 | 2011-5-6 11:47:59 | 显示全部楼层
#include#include#includestruct students{ int number; char name[20]; int score; struct students * next;};void main(){struct students * head , * tail , * p;int num,score;int number;int size = sizeof(struct stude
回复

使用道具 举报

千问 | 2011-5-6 11:47:59 | 显示全部楼层
#include #include #include struct students {int number;char name[20];int score;struct students *next;};int main(void) {
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则