6,8,11,13WA,求助大佬!

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

Lindafish @ 2024-01-30 22:41:12

#include<stdio.h>

int main() {
    int T;
    scanf("%d",&T);
    if (T == 1) {
        printf("I love Luogu!");
    } else if (T == 2) {
        int a=6,b=4;
        printf("%d %d",a,b);
    } else if (T == 3) {
        int x=3,y=12,z=2;
        printf("%d\n%d\n%d\n",x,y,z);
    } else if (T == 4) {
        int mount=500;
        double answer=1.0*500/3;
        printf("%.3f",answer);
    } else if (T == 5) {
        printf("15");
    } else if (T == 6) {
        double a=6.0,b=9.0;
        double c=sqrt(a*a+b*b);
        printf("%f",c);
    } else if (T == 7) {
        int money=100,add=10,cost=20,none=0;
        printf("%d\n%d\n%d\n",money+add,money+add-cost,none);
    } else if (T == 8) {
        int r=5;
        double pai=3.141593;
        double c=2.0*pai*r;
        double s=1.0*pai*r*r;
        double v=4.0*pai*r*r*r/3.0;
        printf("%f\n%f\n%f\n",c,s,v);
    } else if (T == 9) {
        printf("22");
    } else if (T == 10) {
        printf("9");
    } else if (T == 11) {
        double a=100.0,b=3.0;
        double c=a/b;
        printf("%f",c);
    } else if (T == 12) {
        printf("13\n");
        printf("R");
    } else if (T == 13) {
        double pai=3.141593;
        int r1=4,r2=10;
        double v1=4.0*pai*r1*r1*r1/3.0;
        double v2=4.0*pai*r2*r2*r2/3.0;
    } else if (T == 14) {
        printf("50");
    }
    return 0;
}

by Lindafish @ 2024-01-30 22:42:32

请问部分使用cout是要求必须使用c++语言吗?


by penguin_is_cool @ 2024-01-30 22:48:57

@Lindafish 没有吧,而且你是不会算还是忘输出了?


by penguin_is_cool @ 2024-01-30 22:50:10

你第十三题好像没输出


by penguin_is_cool @ 2024-01-30 22:55:26

@Lindafish 1、首先,第六题说直接用cout的意思就是输出整数,没有多余要求,所以printf("%d",c);就行了

2、第八题,圆的体积公式为:(4.0/3.0)pairrr

3、第十一题一样,直接printf("%d",c);

4、第十三题要先补个输出


by Lindafish @ 2024-01-30 22:57:27

@penguin_is_cool 谢谢大佬!13题那个是我之前改了几次都是一输出编译就失败所以我先删了ε=(´ο`*)))


by penguin_is_cool @ 2024-01-30 22:57:32

@Lindafish 你错的4道题都没有浮点数,不要用double


by Lindafish @ 2024-02-01 14:47:04

@penguin_is_cool 大佬能再请教一下吗?那几个我改成整型之后还是WA,分数难道不用double吗?o(╥﹏╥)o


by Lindafish @ 2024-02-01 14:48:25

@penguin_is_cool ```c


#include<stdio.h>

int main() {
    int T;
    scanf("%d",&T);
    if (T == 1) {
        printf("I love Luogu!");
    } else if (T == 2) {
        int a=6,b=4;
        printf("%d %d",a,b);
    } else if (T == 3) {
        int x=3,y=12,z=2;
        printf("%d\n%d\n%d\n",x,y,z);
    } else if (T == 4) {
        int mount=500;
        double answer=1.0*500/3;
        printf("%.3f",answer);
    } else if (T == 5) {
        printf("15");
    } else if (T == 6) {
        int a=6,b=9;
        int c=sqrt(a*a+b*b);
        printf("%d",c);
    } else if (T == 7) {
        int money=100,add=10,cost=20,none=0;
        printf("%d\n%d\n%d\n",money+add,money+add-cost,none);
    } else if (T == 8) {
        int r=5;
        double pai=3.141593;
        double c=2.0*pai*r;
        double s=1.0*pai*r*r;
        double v=(4.0/3.0)*pai*r*r*r;
        printf("%f\n%f\n%f\n",c,s,v);
    } else if (T == 9) {
        printf("22");
    } else if (T == 10) {
        printf("9");
    } else if (T == 11) {
        int a=100.0,b=3.0;
        int c=a/b;
        printf("%d",c);
    } else if (T == 12) {
        printf("13\n");
        printf("R");
    } else if (T == 13) {
        double pai=3.141593;
        int r1=4,r2=10;
        double v1=4.0*pai*r1*r1*r1/3.0;
        double v2=4.0*pai*r2*r2*r2/3.0;
    } else if (T == 14) {
        printf("50");
    }
    return 0;
}
这个是我改完之后的(ಥ﹏ಥ)

by penguin_is_cool @ 2024-02-01 21:11:16

@Lindafish 好像这些题必须要用cout。第六题你输出保留4位小数作一下弊,保留4位小数,应为算法对的。


|