#include
/* User Code Begin(考生可在本行后添加代码,例如结构体的定义、函数原型声明等,行数不限) */
struct stu
{
char name[10], num[10];
int score;
};
void input(struct stu stud, int num);
void output(struct stu *stud, int num);
/ User Code End(考生添加代码结束) */
int main(void)
{
struct stu stud[5];
input(stud, 5);
printf("\nfailed the exam: ");
output(stud, 5);
return 0;
}
/* User Code Begin(考生在此后完成自定义函数的设计,行数不限) */
void input(struct stu *stud, int n)
{
int i, count = 0;
printf("input name number score:\n");
for (i = 0; i < n; i++)
{
do
{
count++;
printf("student %d:", count);
scanf("%s%s%d", (stud + i)->name, (stud + i)->num, &(stud + i)->score);
if ((stud + i)->score < 0 || (stud + i)->score > 100)
{
printf(" error score! input again!\n");
count--;
}
}while ((stud + i)->score < 0 || (stud + i)->score > 100);
}
}
void output(struct stu *stud, int n)
{
int i, flag = 0;
for (i = 0; i < n; i++)
{
if ((stud + i)->score < 60)
{
printf("%s/%s,%d ", (stud + i)->num, (stud + i)->name, (stud + i)->score);
}
flag = 1;
}
if (flag == 0)
{
printf("Not Find!");
}
putchar('\n');
}