又发了个白痴问题,可是对于C语言我就是个白痴,渴望某位大侠提携啊!
其实原来要求用结构体和指针的,可惜小的学业不精,只鼓捣出这么个东西,还是错的,没脸见人啊,怎奈有些东西不得不会,所以只好发出来请教诸位前辈,还望不吝赐教!!/*编写一个程序,输入n个学生的学号,姓名,3门课程的成绩,求出总分最高的学生并输出该学生的所有信息*/
#include <stdio.h>
#define size 80
main()
{
int n,i;
int studentID[size];
char studentName[size];
int scoreComputer[size];
int scoreEnglish[size];
int scoreMath[size];
int sum[size];
int Max,a;
printf("please enter the total number:");
scanf("%d",&n);
printf("please enter the information of everybody:\n");
for (i=0;i<n;i++)
{
scanf("%d",&studentID);
scanf("%c",&studentName);
scanf("%d",&scoreComputer);
scanf("%d",&scoreEnglish);
scanf("%d",&scoreMath);
}
for (i=0;i<n;i++)
{
sum[i]=scoreComputer[i]+scoreEnglish[i]+scoreMath[i];
}
Max=sum[0];
for (i=0;i<n;i++)
{
if (sum[i]>Max)
{
Max=sum[i];
a=i;
}
}
printf("ID:%d,Name:%c,Computer:%d,English:%d,Math:%d\n",studentID[a],studentName[a],
scoreComputer[a],scoreEnglish[a],scoreMath[a]);
}