jzxx2671C语言程序设计教程(第三版)课后习题11.3

题目描述
现有有N个学生的数据记录,每个记录包括学号、姓名、三科成绩。 编写一个函数input,用来输入一个学生的数据记录。 编写一个函数print,打印一个学生的数据记录。 在主函数调用这两个函数,读取N条记录输入,再按要求输出。 N<100

输入
学生数量N占一行 每个学生的学号、姓名、三科成绩占一行,空格分开。

输出
每个学生的学号、姓名、三科成绩占一行,逗号分开。

样例输入
2
a100 zhblue 70 80 90
b200 newsclan 90 85 75

样例输出
a100,zhblue,70,80,90
b200,newsclan,90,85,75

传送门

满分代码:
#include<bits/stdc++.h>
using namespace std;
struct stu {
	char num[30];
	char name[30];
	int a,b,c;
} stu;
int main() {
	int n;
	scanf("%d",&n);
	while(n--) {
		scanf("%s %s %d %d %d",stu.num,stu.name,&stu.a,&stu.b,&stu.c);
		printf("%s,%s,%d,%d,%d\n",stu.num,stu.name,stu.a,stu.b,stu.c);
	}
}

猜你喜欢

转载自blog.csdn.net/lyz060510/article/details/88636658
今日推荐