#include <stdio.h>
#define N 2
struct studenttype
{
char no[10],name[10];
double foreign,spec1,spec2;
double total;
};
void inputmarks(struct studenttype student[],int n);
void addmarks(struct studenttype student[],int n);
void outputmarks(struct studenttype student[],int n);
int main(){
struct studenttype stu[N];
inputmarks(stu,N);
addmarks(stu,N);
printf("各个考生的总成绩为:\n");
outputmarks(stu,N);
return 0;
}
void inputmarks(struct studenttype student[],int n){
int i;
for(i=0;i<n;i++){
printf("请输入第%d个考生的考号",i+1);
scanf("%s",student[i].no);
printf("请输入第%d个考生的姓名",i+1);
scanf("%s",student[i].name);
printf("请输入第%d个考生的外语成绩",i+1);
scanf("%lf",&student[i].foreign);
printf("请输入第%d个考生的专业课1成绩",i+1);
scanf("%lf",&student[i].spec1);
printf("请输入第%d个考生的专业课2成绩",i+1);
scanf("%lf",&student[i].spec2);
}
return;
}
void addmarks(struct studenttype student[],int n){
int i;
for(i=0;i<n;i++){
student[i].total=student[i].foreign+student[i].spec1+student[i].spec2;
}
return;
}
void outputmarks(struct studenttype student[],int n){
int i;
for(i=0;i<n;i++){
printf("%s的总分是%lf\n",student[i].name,student[i].total);
}
return;
}