从键盘输入某个星期每一天的最高温度和最低温度,然后计算该星期的平均最高和最低温度并输出

来源:百度知道 编辑:UC知道 时间:2024/05/21 14:33:40
写全了啊

/*从键盘输入某个星期每一天的最高温度和最低温度,然后计算该星期的平均最高和最低温度并输出*/
#include<iostream>
using namespace std;
struct tempreater
{
float high[7];
float low[7];
float high1;
float low1;
}tem;
int main()
{
tem.high1=0;
tem.low1=0;
cout<<"请输入一星期中每一天的最高温度和最低温度:\n";
for(int i=0;i<7;i++)
{
cout<<"星期"<<i+1<<'\t';
cin>>tem.high[i]>>tem.low[i];
tem.high1+=tem.high[i];
tem.low1+=tem.low[i];
}
cout<<"该星期的平均最高温度为:"<<tem.high1/7<<endl
<<"该星期的平均最低温为:"<<tem.low1/7<<endl;
return 0;
}