各位大侠?c++里怎样编辑两个数同时求和、平均值和最大值??

来源:百度知道 编辑:UC知道 时间:2024/07/04 18:47:27
原题是:

设计一个程序,要求对某一小学生的语文、数学两门功课得分进行运算,输出两门功课的总分、平均分和最高分!

望 最好能给注释一下!谢谢!不注释也行!急用啊…………

Thanks!!

#include<iostream>
using namespace std;
int main() //主函数
{ double math, chinese,sum, avg, max; //double型变量
cout<<"请分别输入数学和语文的成绩:"<<endl;
cin>>math>>chinese; //输入
sum = (math+chinese) ; //和
avg = sum/2; //平均
max = (math > chinese? math : chinese); //最大
cout<<"总分为:"<<sum<<endl;
cout<<"平均分为:"<<avg<<endl;
cout<<"最高分为:"<<max<<endl;
}

VC++ 6.0下通过编译并运行成功 o(∩_∩)o
--------------------------------------------------------------
#include <iostream>
using namespace std;

int main(){
double math,chinese;
double total,avg,high;
cout<<"请输入你的数学 语文 两门功课的分数: ";
cin>>math
>>chinese;
total =(math + chinese);
avg = total/2;
high =(math>chinese?math:chinese);<