90pts求助

B2088 计算书费

Suge_Stephen @ 2024-04-05 09:27:31

#import<iostream>
using namespace std;
float s,n;
int a[15],i;
int main(){

    for(int i=0;i<10;i++){
        cin>>a[i];
        if(i==0) n=28.9;
        if(i==1) n=32.7;
        if(i==2) n=45.6;
        if(i==3) n=78.0;
        if(i==4) n=35.0;
        if(i==5) n=86.2;
        if(i==6) n=27.8;
        if(i==7) n=43.0;
        if(i==8) n=56.0;
        if(i==9) n=65.0;
        s+=a[i]*n;
    }cout<<s;

    return 0;
}

by Dream_Creator @ 2024-04-05 09:30:43

@Suge_Stephen


#import<iostream>
using namespace std;
float s,n;
int a[15],i;
int main(){

    for(int i=0;i<10;i++){
        cin>>a[i];
        if(i==0) n=28.9;
        if(i==1) n=32.7;
        if(i==2) n=45.6;
        if(i==3) n=78.0;
        if(i==4) n=35.0;
        if(i==5) n=86.2;
        if(i==6) n=27.8;
        if(i==7) n=43.0;
        if(i==8) n=56.0;
        if(i==9) n=65.0;
        s+=a[i]*n;
    }printf("%.1f",s);

    return 0;
}

by Suge_Stephen @ 2024-04-05 09:52:15

@Dream_Creator 感谢


|