以下程序可以在vc6.0当中实现
#include
void
main()
{
float
a,b,c,d,e,average,sum;
cout<<"Input
your
five
number:"<
sum=a+b+c+d+e;
average=sum/(float)5;
cout<<"The
sum
is:"<
average
is:"<
以下程序可以在vc6.0当中实现
#include
void main()
{
float a,b,c,d,e,average,sum;
cout<<"Input your five number:"<
sum=a+b+c+d+e;
average=sum/(float)5;
cout<<"The sum is:"<
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);
}
#include
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
void
main()
{
float
a,b,c,d,e,average,sum;
cout<<"Input
your
five
number:"<
sum=a+b+c+d+e;
average=sum/(float)5;
cout<<"The
sum
is:"<
average
is:"<