《90分》《神犇勿喷》《求助大佬》

B2088 计算书费

vector_STL_ @ 2024-08-19 18:55:38

#include<bits/stdc++.h>
using namespace std;
int main(){
    long long a[15];
    cin>>a[1]>>a[2]>>a[3]>>a[4]>>a[5]>>a[6]>>a[7]>>a[8]>>a[9]>>a[10];
    cout<<a[1]*28.9+a[2]*32.7+a[3]*45.6+a[4]*78+a[5]*35+a[6]*86.2+a[7]*27.8+a[8]*43+a[9]*56+a[10]*65;
    return 0;
} 

by gongziwen @ 2024-08-19 18:57:15

@zch120526 《输出格式》《包含一个实数》《精确到小数点后一位》


by zhizhenyaohanyu @ 2024-08-19 19:00:10

要保留小数点后1位,下次记得看输出格式@zch120526


by sean0613 @ 2024-08-19 19:10:08

@zch120526 《后一位


by BlackWuKong @ 2024-08-19 19:10:36

@zch120526 我的思路:

#include<bits/stdc++.h>
using namespace std;
int main(){
    double p[110]={0,28.9,32.7,45.6,78,35,86.2,27.8,43,56,65},m=0;
    int a;
    for (int i=1;i<=10;i++){
        cin>>a;
        m+=a*p[i];
    }
    printf("%.1lf",m);
    return 0;
}

求关


by lce11451410086 @ 2024-08-23 13:32:33

@zch120526 我的思路


#include<bits/stdc++.h>
using namespace std;
int main(){
    double a[10]={28.9,32.7,45.6,78,35,86.2,27.8,43,56,65};
    double sum=0;
    for(auto p:a){
        int x;
        cin>>x;
        sum+=x*p;
    }
    printf("%.1lf",sum);
    return 0;
}

by chenzhishuo2012 @ 2024-09-05 07:34:11

@zch120526 求互关

#include<bits/stdc++.h>
using namespace std;
int a[20];
double b[20]={0,28.9,32.7,45.6,78,35,86.2,27.8,43,56,65},ans;
int main(){
    for(int i=1;i<=10;i++){
        cin>>a[i];
        ans+=a[i]*b[i];
    }
    printf("%0.1lf",ans);
    return 0;
}

by zycEthan @ 2024-12-04 20:16:47

我的思路:

#include<bits/stdc++.h>
using namespace std;
int main(){
    float a[10]={28.9,32.7,45.6,78,35,86.2,27.8,43,56,65},x=0;
    int i,n;
    for (i=0;i<10;i++){
        cin >> n;
        x+=n*a[i];
    }
    cout << x*1.0;
}

}


|