3,6,8,11,咋就那过不去呢,

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

24KB24 @ 2022-01-14 17:38:39


#include <stdio.h>
#include <math.h>
int main() {
    int T;
    scanf("%d", &T);
    if (T == 1) {

        printf( "I love Luogu!");
    } else if (T == 2) {
        printf("%d ", 2 + 4);
        printf("%d", 4);
    } else if (T == 3) {
        int n;
        n = 14 / 3;
        printf("%d\n%d\n%d\n", n,n*3,14-n*3);
    } else if (T == 4) {
        printf("%.3f", 500 * 1.0 / 3);
    } else if (T == 5) {
        printf("%d", (260 + 220) / (12 + 20))  ;
    } else if (T == 6) {
        printf("%f", sqrt(6 * 6 + 9 * 9));
    } else if (T == 7) {
        printf("%d\n%d\n%d", 100 + 10, 110 - 20, 0);
    } else if (T == 8) {
        float pai = 3.141593;
        int r = 5;
        printf("%f\n%f\n%f", 2 * pai * r, pai * r * r, (4 * 1.0 / 3)*pai * r * r * r);
    } else if (T == 9) {
        printf("%d", 22);
    } else if (T == 10) {
        printf("%d", 9);
    } else if (T == 11) {
        printf("%f", 100 * 1.0 / 3);
    } else if (T == 12) {
        printf("%d\n", 'M' - 'A' + 1);
        printf("%c", 'A' + 17);
    } else if (T == 13) {
        float pi = 3.141593;
        printf("%.0f", pow((4 * 1.0 / 3 * pi * (4 * 4 * 4 + 10 * 10 * 10)), 1 * 1.0 / 3));

    } else if (T == 14) {
        printf("%d", 50);
    }
    return 0;
}

by hopeless_hope @ 2022-01-14 18:16:44

@24KB24 8中 float改成double


by 24KB24 @ 2022-01-15 14:40:16

@whoam 谢谢哦,好像也不行


by yangyang1000 @ 2022-01-28 12:01:18

第六题改成cout就能过。


by yangyang1000 @ 2022-01-28 12:02:07

cout<<sqrt(66+99);


by yangyang1000 @ 2022-01-28 12:03:57

11题和6题一样


by yangyang1000 @ 2022-01-28 12:06:14

cout<<100.0/(8-5); 更重要的是不能这么乘,再除就变成整数


by laibanet @ 2022-02-18 00:32:53

6题C语言有个默认保留6位有效数字,可以用%.4f


by laibanet @ 2022-02-18 00:35:30

@laibanet 保留有效数字的说法不对,,我试过保留的那种不行


by UTAsriel @ 2022-10-10 09:20:54

@yangyang1000 他用的是C语言不是C++……


|