| 
 | 
 
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册  
 
x
 
#include <stdio.h> 
#include <malloc.h> 
 struct node 
 { 
         char name[10]; 
     int num,score; 
     struct node *next; 
 }; 
    struct node *create() 
        { 
                printf("请输入学生的信息,以输入学号为0结束\n"); 
                printf("\t学号\t姓名\t分数\n"); 
                struct node *Head,*p,*tail; 
                int date; 
                Head = (struct node *)malloc(sizeof(struct node)); 
                Head->next = NULL; 
                tail = Head; 
                p = (struct node *)malloc(sizeof(struct node)); 
                p->next = NULL; 
                while(scanf("%d",&date) != EOF) 
                { 
                        if(date == 0) break; 
                        p->num = date; 
                        scanf("%s %d",p->name,&p->score); 
                        tail->next = p; 
                        tail = p; 
                        p = (struct node *)malloc(sizeof(struct node)); 
                        p->next = NULL; 
                } 
                system ("pause"); 
                return Head; 
        } 
        void print(struct node *Head) 
        { 
                printf("\t\t学生信息输出\n"); 
                printf("\t学号\t姓名\t分数\n"); 
                struct node *p; 
                p = Head->next; 
                while(p != NULL) 
                { 
                        printf("\t%d\t%s\t%d\n",p->num,p->name,p->score); 
                        p = p->next; 
                } 
        } 
        int main() 
        { 
                struct node *head; 
                head = create(); 
print(head); 
system ("pause"); 
return 0; 
        } 
 |   
 
 
 
 |