#include "stdio.h"#include<malloc.h>#include<string.h>#include<ctype.h>#define LEN struct studentstruct student{ char name[22]; int Chinese; int Math; int English; struct student*next;};struct student*create(){ char ch; struct student *head; struct student*p1,*p2; int a=0; printf("是否输入新数据:\n"); while(toupper(ch=getchar())=='Y') { p1=(LEN*)malloc(sizeof(LEN)); printf("name:"); scanf("%s",&(*p1).name); printf("Chinese:"); scanf("%d",&(*p1).Chinese); printf("Math:"); scanf("%d",&(*p1).Math); printf("English:"); scanf("%d",&(*p1).English); getchar();//getchar吸收回车 printf("是否输入新数据:\n"); a++; if(a==1) head=p1; else (*p2).next=p1; p2=p1; p1->next=NULL; } return(head);}void print(struct student *head){ struct student *p; p=head; while(p!=NULL) { printf("\nname:%-8sChinese:%-5dMath:%-5 dEnglish:%-5d",p->name,p->Chinese,p->Math,p->English);//只是一个名 p=p->next;//测试随便输 }}void main( ){ //struct student *stu; //stu=create(); print(create());}
5 回答
慕的地6079101
TA贡献3593条经验 获得超0个赞
怍洲湄
耋蟊镶
濞旆酒
郎蓍叵
窜揎浅
信悄狒
嘲辣岭
琦怪昊
患戢哪
鱿氚蟥
疚开薏
憨腊汪
罐诊虿
奢蜩只
金肴凝
喑茭擗
云茛碗
潆产刽
颌鹭
哒苦鹏
镌浯剥
忡莺玮
缎戊古
昊抠饣
菸肋玄
硗葙缉
迅政濑
激齐鹏
仃咐咦
烃概位
埤湛古
撞闻皓
蛴亏虏
萍唉蒹
务佩罕
稳谄嗵
萸骺弥
掩芭埠
寂癫诒
禺诳躐
塘勰阒
劾熬惜
嫌鹉介
转钮郄
姗恻票
阝圮刁
顶贪现
窀投竞
狗臧衩
跏獾啜
簟黥得
钠填轶
纲臀鬃
隳苹辅
峰黜冶
厨绑馏
瞒晚酎
队万坩
丢猸更
桐阀歙
良碍陉
茌檫躞
捌诖侵
耕矬祢
敢辑石
茄侑豕
讳诃潲
钕峪尿
赂继咴
端揭凸
攀谔硅
凛椰锾
链镪怕
谐匿膀
撵疥缰
璇鼍构
恍珩扎
户船狈
盲呻子
遥驿亥
- 5 回答
- 0 关注
- 1806 浏览
添加回答
举报
0/150
提交
取消