A股上市公司传智教育(股票代码 003032)旗下技术交流社区北京昌平校区

 找回密码
 加入黑马

QQ登录

只需一步,快速开始

© 牛牛很牛 中级黑马   /  2017-8-14 09:06  /  1559 人查看  /  0 人回复  /   0 人收藏 转载请遵从CC协议 禁止商业使用本文

一共是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 
}




0 个回复

您需要登录后才可以回帖 登录 | 加入黑马