一共是9个填空,有些思路,但具体语法不怎么会,求助论坛各位大神帮忙解答一下,多谢
[C] 纯文本查看 复制代码 #define STUDENT_SIZE (3)
typedef struct ScoreInfo{//分数信息
int mathScore;
int chineseScore;
int englishScore;
}ScoreInfo;
typedef struct StudentInfo{//学生信息 包含分数信息
char stuName[10];
int stuID;
int stuAge;
ScoreInfo stuScore;
}StudentInfo;
void displayStuInfo(StudentInfo stu[],int pos); //打印最高分学生详细信息
bool sumScore(StudentInfo* pStu,int *pSumArray); //计算总分
int findFirst(StudentInfo* pStu); //查找最高分数的学生 返回学生序号
int main(){
StudentInfo stuArray[STUDENT_SIZE]=({"Lisa",1,12,{25,80,75}},{"Tom",2,13,{85,70,80}},{"Lucy",3,12,{100,90,99}});
int pos=0; //最高分学生的下标
pos=findFirst( ); //1
if( ){ //2 NULL==pos
printf("\nError,please check");
}else{
displayStuInfo(stuArray,pos); //打印最高分学生详细信息
}
return 0;
}
bool sumScore(StudentInfo* pStu,int *pSumArray){
if(NULL==pStu){
return false;
}
if(NULL==pSumArray){
return false;
}
int i=0;
for(i=0;i<STUDENT_SIZE;i++){
pSumArray[i]=( ); //3
}
return true;
}
int findFirst(StudentInfo* pStuArray){
if(NULL==pStuArray){
return -1;
}
int sumArray[STUDENT_SIZE]= ; //4
int firstPos=0;
int ret=true;
int maxScore=0;
int t;
if(false==sumScore( )){ //5
return -1;
}
maxScore=sumArray[0];
for(i=1;i<STUDENT_SIZE;i++){
if(maxScore<sumArray[i]){
maxScore=sumArray[i];
//6 记录位置
}
}
return firstPos;
}
void displayStuInfo(StudentInfo stu[],int pos){
printf("\n name:%s",stu[pos].stuName);
printf("\n ID:%d",stu[pos].stuID);
printf("\n Age:%d",stu[pos].stuAge);
printf("\n Math %d", ); //7
printf("\n Chinese %d", ); //8
printf("\n English %d", ); //9
}
|