Run ID 作者 问题 语言 测评结果 Time Memory 代码长度 提交时间
134434 whs 04保留两位小数 C++ Compile Error 0 MS 0 KB 164 2025-10-27 16:59:20

Tests(0/0):


Code:

#include <iostream> using namespace std; int main(){ int a,b,c,d; double a=5.0; double b=2.5; printf("%.2lf",a); printf("%.2lf",b); }


Run Info:

Main.cc: In function 'int main()':
Main.cc:5:11: error: conflicting declaration 'double a'
    double a=5.0;
           ^
Main.cc:4:8: note: previous declaration as 'int a'
    int a,b,c,d;
        ^
Main.cc:6:13: error: conflicting declaration 'double b'
      double b=2.5;
             ^
Main.cc:4:10: note: previous declaration as 'int b'
    int a,b,c,d;
          ^
Main.cc:7:20: warning: format '%lf' expects argument of type 'double', but argument 2 has type 'int' [-Wformat=]
    printf("%.2lf",a);
                    ^
Main.cc:8:22: warning: format '%lf' expects argument of type 'double', but argument 2 has type 'int' [-Wformat=]
      printf("%.2lf",b);
                      ^
Main.cc:4:12: warning: unused variable 'c' [-Wunused-variable]
    int a,b,c,d;
            ^
Main.cc:4:14: warning: unused variable 'd' [-Wunused-variable]
    int a,b,c,d;
              ^