中易网

在上一题的基础上,编写一个函数input,用来输入5个学生的数据记录

答案:1  悬赏:40  
解决时间 2021-02-17 15:32
在上一题的基础上,编写一个函数input,用来输入5个学生的数据记录
最佳答案
#include
#include
#include
typedef struct Info
{
int num;
char name[21];
float score[3];
}DATA;
void print(DATA *SInfo,int n)
{
int i;
printf("%-4s%-21s%8s%8s%8s\n","num","name","score1","score2","score3");
for(i=0;i{
printf("%-4d%-21s%8.1f%8.1f%8.1f\n",SInfo[i].num,SInfo[i].name,SInfo[i].score[0],SInfo[i].score[1],SInfo[i].score[2]);

}
}
void input(DATA *SInfo)
{
int i;
printf("Please Input 5 student Info !\n");
for(i=0;i<5;i++)
{
printf("Please Input the %d student Info:",i+1);
printf("\nPlease Input the num:");
scanf("%d",&SInfo[i].num);
fflush(stdin);
printf("Please Input the name:");
scanf("%s",SInfo[i].name);
fflush(stdin);
printf("Please Input the score:");
scanf("%f%f%f",&SInfo[i].score[0],&SInfo[i].score[1],&SInfo[i].score[2]);
fflush(stdin);
}
}
void main()
{
DATA StuInfo[5];
int n;
input(StuInfo);
n=sizeof(StuInfo)/sizeof(DATA);
while(StuInfo[n].name[0]!='\0')
{
n++;
}
print(StuInfo,n);
getch();
}
我要举报
如以上问答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
如何养水蚯蚓
大话西游2电脑配置
百佳名妆地址在什么地方,我要处理点事
请各位来交流下如何让画眉上膘~
AMD 速龙II X4 651相当于INTEL的什么水平
电脑平车显示屏显示E_07是什么意思?
NObody but three students___in the classro
初三分流合不合法
关于门面,做生意,有一条街人很多生意都很好
苏州元旦有哪些景区好看好玩的啊?门票又是多
求牛肉品牌起名 最好2 3个字的
QQ相册容量是多少?
为什么肥料越用越多,蔬菜产量却越来越低
停车场(出入口)(文昌路611号附近停车场)怎么
上午我把我的狗丢了 现在中午天很热 宠物狗一
推荐资讯
日本的农业特点。要具体
男唱歌词带走要知道想你的时候,就知道是什么
我申请了建行龙卡e付卡,但不小心把发给我的
泉水受污染了的危害是什么
小米3手机掉水里了,放了一天,开不开机了,
中国国内的武术散打,哪个省的实力最强?排名
被厂里的老阿姨欺负了,我把那个阿姨臭骂了一
古代宫殿常用的琉璃瓦在颜色上都有哪些讲究
what have you done什么意思
为什么微信无法搜查手机通讯录的好友
我家接的是电信20M光纤。然后就是,我的电脑
兰州新区有到武威的高铁吗
手机登qq时,显示手机磁盘不足,清理后重新登
刺客的套装怎么选啊?