/**************************************************************
* Copyright (c) 2013, 西华师范大学计算机学院
* All rights reserved.
* 作 者: 曾舜尧
* 完成日期:2013 年 05 月 21 日
* 工 具:VC6.0
*
* 输入描述:
* 问题描述: 在第3题的基础上编写一个函数input,用来输入5个学生的成绩。
* 程序输出:
* 问题分析:略
* 算法设计:略
**************************************************************/
#include <stdio.h>
#include <stdlib.h>
#define N 5/*定义五个学生*/
struct student
{
int num;
char name[10];
float score[3];
};
struct student stu[N];
int main()
{
void print(int n);/*struct student stu[],int n*/
/*struct student*/void input (int n);/*struct student stu[],int n*/
printf("\007请输入五个学生的成绩:\n");
input(N);
print(N);
system("pause");
return 0;
}
void print(/*struct student stu[],*/int n)
{
int i;
printf("学号\t姓名\t语文 数学 英语\n");
for (i=0;i<n;i++)
{
printf("%2d\t%s\t%3.2f %3.2f %3.2f\n",stu[i].num,stu[i].name,stu[i].score[0],stu[i].score[1],stu[i].score[2]);
}
//
return ;
}
/*struct student */void input (/*struct student stu[],*/int n)
{
int i;
for (i=0;i<n;i++)
{
printf("\007请输入%d个学生的学号:",i+1);
scanf("%d",&stu[i].num);
printf("请输入姓名:");
scanf("%s",stu[i].name);
printf("请输入是3各科目的成绩:");
scanf("%f%f%f",&stu[i].score[0],&stu[i].score[1],&stu[i].score[2]);
}
return /*stu*/;
}
转载于:https://blog.51cto.com/69680919/1206738