有点傻的方法
#include<bits/stdc++.h>
using namespace std;
int main()
{
double a,b,c,d,e,f,g,h,j,k,res;
cin>>a>>b>>c>>d>>e>>f>>g>>h>>j>>k;
a=a*28.9;
b=b*32.7;
c=c*45.6;
d=d*78;
e=e*35;
f=f*86.2;
g=g*27.8;
h=h*43;
j=j*56;
k=k*65;
res=a+b+c+d+e+f+g+h+j+k;
printf("%.1f",res);
return 0;
}
数组
#include<bits/stdc++.h>
float a[10]={28.9,32.7,45.6,78,35,86.2,27.8,43,56,65},x=0;
using namespace std;
int main()
{
int i,num;
for (i=0;i<10;i++)
{
cin >> num;
x += num*a[i];
}
cout << fixed << setprecision(1) << x;
return 0;
}
标签:int,书费,namespace,43,1104,num,65,奥赛,res
From: https://blog.csdn.net/lsoixwx/article/details/145159575