C++编程 从键盘输入5个浮点数,求出其和及平均值。
5个回答
展开全部
以下程序可以在vc6.0当中实现
#include<iosream.h>
void
main()
{
float
a,b,c,d,e,average,sum;
cout<<"Input
your
five
number:"<<endl;
cin>>a>>b>>c>>d>>e;
sum=a+b+c+d+e;
average=sum/(float)5;
cout<<"The
sum
is:"<<sum<<endl;
cout<<"The
average
is:"<<average<<endl;
}
#include<iosream.h>
void
main()
{
float
a,b,c,d,e,average,sum;
cout<<"Input
your
five
number:"<<endl;
cin>>a>>b>>c>>d>>e;
sum=a+b+c+d+e;
average=sum/(float)5;
cout<<"The
sum
is:"<<sum<<endl;
cout<<"The
average
is:"<<average<<endl;
}
展开全部
以下程序可以在vc6.0当中实现
#include<iosream.h>
void main()
{
float a,b,c,d,e,average,sum;
cout<<"Input your five number:"<<endl;
cin>>a>>b>>c>>d>>e;
sum=a+b+c+d+e;
average=sum/(float)5;
cout<<"The sum is:"<<sum<<endl;
cout<<"The average is:"<<average<<endl;
}
#include<iosream.h>
void main()
{
float a,b,c,d,e,average,sum;
cout<<"Input your five number:"<<endl;
cin>>a>>b>>c>>d>>e;
sum=a+b+c+d+e;
average=sum/(float)5;
cout<<"The sum is:"<<sum<<endl;
cout<<"The average is:"<<average<<endl;
}
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
main
{ float a[5],sum,average;
int i;
for(i=0;i<5;i++)
{scanf("%f",&a[i]);
sum+=a[i];}
average=sum*1.0/8;
printf("和是%f,平均值是%f",sum,average);
}
{ float a[5],sum,average;
int i;
for(i=0;i<5;i++)
{scanf("%f",&a[i]);
sum+=a[i];}
average=sum*1.0/8;
printf("和是%f,平均值是%f",sum,average);
}
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
#include<iostream>
using namespace std;
int main()
{
float a[5];
float sum = 0;
for(int j = 0; j < 5; j++)
{
cout << "请输入第" << j + 1 << "个数据";
cin >> a[j];
}
for(int i = 0; i < 5; i++)
{
sum += a[i];
}
cout << "the sum is " << sum << endl;
cout << "the average is " << sum/5 << endl;
return 0;
}
using namespace std;
int main()
{
float a[5];
float sum = 0;
for(int j = 0; j < 5; j++)
{
cout << "请输入第" << j + 1 << "个数据";
cin >> a[j];
}
for(int i = 0; i < 5; i++)
{
sum += a[i];
}
cout << "the sum is " << sum << endl;
cout << "the average is " << sum/5 << endl;
return 0;
}
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
程序
vc6.0
实现
#include<iosream.h>
void
main()
{
float
a,b,c,d,e,average,sum;
cout<<"Input
your
five
number:"<<endl;
cin>>a>>b>>c>>d>>e;
sum=a+b+c+d+e;
average=sum/(float)5;
cout<<"The
sum
is:"<<sum<<endl;
cout<<"The
average
is:"<<average<<endl;
}
vc6.0
实现
#include<iosream.h>
void
main()
{
float
a,b,c,d,e,average,sum;
cout<<"Input
your
five
number:"<<endl;
cin>>a>>b>>c>>d>>e;
sum=a+b+c+d+e;
average=sum/(float)5;
cout<<"The
sum
is:"<<sum<<endl;
cout<<"The
average
is:"<<average<<endl;
}
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询