为什么我这在Dev c++正常运行,在这就编译失败

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

caik66 @ 2024-10-11 11:39:30

#include <iostream>  
#include <cmath>

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 << 3 << " " << 12 << " " << 2;
    } else if (T == 4) {
        float ml;
        ml = 500 / 3.0f; 
        printf("%.6f\n", ml); 
    } else if (T == 5) {
        cout << 15;
    } else if (T == 6) {
        cout << pow(36+81,1/2);
    } else if (T == 7) {
        cout << 110 << endl;
        cout << 90 << endl;
        cout << 0 << endl;
    } else if (T == 8) {
        int r = 5;
        double pi = 3.141593;
        cout << 2 * pi * r << endl; 
        cout << pi * r * r << endl; 
        cout << 4/3.0 * pi * r * r << endl; 
    } else if (T == 9) {
        int pee = 1;
        pee = (pee + 1) * 2;
        pee = (pee + 1) * 2;
        pee = (pee + 1) * 2;
        cout << pee;
    } else if (T == 10) {
        cout << 9;
    } else if (T == 11) {
        cout << 100.0/3;
    } else if (T == 12) {
        cout << 13 << endl;
        cout << "R";
    } else if (T == 13) {
        float pi = 3.141593;
        float V = 4/3 * pi * 14 * 14 * 14;
        int a = static_cast<int>(pow(V,1/3)); 
        cout << a;
    } else if (T == 14) {
        cout << 50;
    }
    return 0;
}

by _yAy_ @ 2024-10-11 12:13:21

wa65pts


by dongzirui0817 @ 2024-10-11 12:20:00

@caik66 版本不够,C++98太老啦,static_cast<int> 根本用不了


by dongzirui0817 @ 2024-10-11 12:21:33

@caik66 而且 T = 13 的错了 float V = 4/3 * pi * 14 * 14 * 14; 改成 float V = 4.0/3 * pi * 14 * 14 * 14;


by dongzirui0817 @ 2024-10-11 12:23:12

@caik66 而且真诚建议您,最好不要用这样的高科技,到时候挂了直接老实


|