中级光能
#include<iostream>
#include<cstdio>
using namespace std;
int main()
{
double x,sum=0,cnt=0,a;
double s=0;
cin>>a;
do
{
cin>>x;
if(x!=0)
{
sum+=x;
cnt++;
}
}while(x!=0);
s=(sum+a)*1.0/(cnt+1);
if(a<s)
{
cout<<a<<endl;
printf("%.2f\n",s);
cout<<"报考补习班";
}
else if(a>=s)
{
cout<<a<<endl;
printf("%.2f",s);
cout<<"奖励玩具车";
}
return 0;
}
40分........................................................................................................................................................................................................................................
初级光能
定义几个变量: a;bouble b//小明的成绩,c=0,s=0;
输入a后输出并换行;
b存储a的值;
输入,算出一共有多少人和一共的分数
while(a!=0){
计数器c++;
总人数s+=a;
输入cin>>a;}
输出平均分:printf("%.2f",s/c);
换行;
if判断小明的成绩是否大于平均分:
if(s/c>b){
cout<<"报考补习班";
}
else {
cout<<"奖励玩具车";
}
望采纳呀
初级光能
很简单:
while(1){
i++;
cin>>f[i];
cnt+=f[i];
if(f[i]==0) break;
}
m=f[1];
cout<<m<<endl;
i=i-1;
cnt=cnt/i;
printf("%.2f",cnt);
新手天翼
while(1){
i++;
cin>>f[i];
cnt+=f[i];
if(f[i]==0) break;
}
m=f[1];
cout<<m<<endl;
i=i-1;
cnt=cnt/i;
printf("%.2f",cnt);
核心代码,最后比较直接输出!!!