解题思路:
用结构体数组来解决问题
注意事项:
见代码
参考代码:
#include <stdio.h>
typedef struct student
{
char id[20];
char name[20];
int a1;
int a2;
int a3;
}stu;//定义结构体
void input(int n, stu* std)
{
for (int i = 0; i < n; i++)
scanf("%s%s%d%d%d", std[i].id, std[i].name, &std[i].a1, &std[i].a2, &std[i].a3);
}
void output(int n, stu* std)
{
for (int i = 0; i < n; i++)
printf("%s,%s,%d,%d,%d\n", std[i].id, std[i].name, std[i].a1, std[i].a2, std[i].a3);
}
int main(void)
{
int n;
scanf("%d", &n);
stu std[100];//定义结构体数组
input(n, std);
output(n, std);
return 0;
}
0.0分
0 人评分
字符串输入输出函数 (Java代码)浏览:1440 |
C语言程序设计教程(第三版)课后习题6.1 (C语言代码)浏览:609 |
【绝对值排序】 (C++代码)浏览:672 |
C语言程序设计教程(第三版)课后习题7.1 (C语言代码)浏览:1229 |
C语言程序设计教程(第三版)课后习题3.7 (C语言代码)浏览:449 |
WU-拆分位数 (C++代码)浏览:788 |
C语言程序设计教程(第三版)课后习题6.3 (C语言代码)浏览:660 |
C语言程序设计教程(第三版)课后习题9.6 (C语言代码)浏览:586 |
C语言考试练习题_保留字母 (C语言代码)浏览:713 |
2004年秋浙江省计算机等级考试二级C 编程题(1) (C语言代码)浏览:600 |