8、13为什么WA ,求大佬指教!

P2433 【深基1-2】小学数学 N 合一

llw545664934 @ 2022-02-08 23:16:27

#include<iostream>
#include<iomanip>
#include<math.h>
using namespace std;

int main() {
    int T;
    cin >> T;
    if (T == 1) {
        cout << "I love Luogu!";
    } else if (T == 2) {
        cout << 2 + 4 << " " << 10 - 2 - 4;
    } else if (T == 3) {
        cout<<14/4<<endl;
        cout<<(14/4)*4<<endl;
        cout<<14-(14/4)*4<<endl;
    } else if (T == 4) {
    double a=500.0 / 3;
    cout<<fixed<<setprecision(3)<<a<<endl;
    } else if (T == 5) {
    cout<<(260+220)/(20+12)<<endl;
    } else if (T == 6) {
    cout<<sqrt(6*6+9*9);
    } else if (T == 7) {
    int b,c,d,e;
    b=100;
    c=b+10;
    d=c-20;
    e=d-d;
    cout<<c<<endl;
    cout<<d<<endl;
    cout<<e<<endl;
    } else if (T == 8) {
    cout<<2*5*3.141593<<endl;
    cout<<3.1415923*5*5<<endl;
    double q=4/3*3.141593*5*5*5*1.0;
    cout<<q<<endl;
    } else if (T == 9) {
    cout<<(((1+1)*2+1)*2+1)*2;
    } else if (T == 10) {
    cout<<"9"<<endl;
    } else if (T == 11) {
    cout<<100.0/3;
    } else if (T == 12) {
        int f;
        string g;
        f='M'-'A'+1;
        g='A'+17;
        cout<<f<<endl;
        cout<<g;
    } else if (T == 13) {
    double h=pow((4/3)*3.141593*(4*4*4+10*10*10)*1.0,1.0/3);
    int i=(int)h;
    cout<<i;
    } else if (T == 14) {
    cout<<"50"<<endl;
    }
    return 0;
}

by 5k_sync_closer @ 2022-02-09 08:35:07

@llw545664934

8:这一步:

double q=4/3*3.141593*5*5*5*1.0;

4/3 会直接得到整数 1,然后接着往下算。 13.:

double h=pow((4/3)*3.141593*(4*4*4+10*10*10)*1.0,1.0/3);

同样


by llw545664934 @ 2022-02-09 13:02:26

@5k_sync_closer 解决了!膜拜!


|