哪里有C++课程的实例,小弟急用.

来源:百度知道 编辑:UC知道 时间:2024/06/21 23:39:19

#include<stdio.h>
#define N 2
struct sc
{
float math;
float english;
float computer;

};//编写结构体
struct stud
{
int NUM;
char name[20];
char sex;
int age;
struct sc score;//结构体的嵌套
}stu[N];//编写结构体

void main()
{
float max1(float),max2(float),max3(float),sum1(float),sum2(float),sum3(float);//函数的标示
float math_MAX=0,english_MAX=0,computer_MAX=0,math_AVE,english_AVE,computer_AVE;//定义变量
int i;//定义变量
for (i=0;i<N;i++)
{
printf("请输入第%d位学生学号 姓名 年龄 姓别 三科成绩(数学 英语 计算机):\n",i+1);
scanf("%d %s %d %c %f %f %f",&stu[i].NUM,&stu[i].name,&stu[i].age,&stu[i].sex,&stu[i].score.math,&stu[i].score.english,&stu[i].score.computer);
math_MAX=max1(stu[i].score.math);
english_MAX=max2(stu[i].score.english);
computer_MAX=max3(stu[i].score.computer);
math_AVE=sum1(stu[i].score.math);
english_AVE=sum