Mã chấm Tài khoản Bài tập Ngôn ngữ lập trình Trạng thái Thời gian Bộ nhớ Kích thước Thời gian nộp
268047 Trần Phương Thảo Số PI C/C++ Lỗi biên dịch (CE) 0 MS 0 KB 398 2023-11-18 19:45:23

Lỗi biên dịch:

Main.cc:18:12: warning: character constant too long for its type
     printf('Pi = %.5f', pi);
            ^~~~~~~~~~~
Main.cc: In function ‘int main()’:
Main.cc:9:11: error: ‘Epsilon’ does not name a type
     const Epsilon= 1E-4;
           ^~~~~~~
Main.cc:10:13: error: ‘i’ was not declared in this scope
     pi = 4; i = 1; s = -1;
             ^
Main.cc:13:9: error: expected ‘(’ before ‘t’
         t> Epsilon 
         ^
Main.cc:13:12: error: ‘Epsilon’ was not declared in this scope
         t> Epsilon 
            ^~~~~~~
Main.cc:14:5: error: expected ‘)’ before ‘do’
     do
     ^~
Main.cc:16:9: error: expected ‘while’ before ‘s’
         s = -s; i= i+1;
         ^
Main.cc:16:9: error: expected ‘(’ before ‘s’
Main.cc:16:11: warning: suggest parentheses around assignment used as truth value [-Wparentheses]
         s = -s; i= i+1;
         ~~^~~~
Main.cc:16:15: error: expected ‘)’ before ‘;’ token
         s = -s; i= i+1;
               ^
Main.cc:18:27: error: invalid conversion from ‘int’ to ‘const char*’ [-fpermissive]
     printf('Pi = %.5f', pi);
                           ^
In file included from /usr/include/stdio.h:862:0,
                 from Main.cc:1:
/usr/include/x86_64-linux-gnu/bits/stdio2.h:102:1: note:   initializing argument 1 of ‘int printf(const char*, ...)’
 printf (const char *__restrict __fmt, ...)
 ^~~~~~
Main.cc:8:9: warning: unused variable ‘n’ [-Wunused-variable]
     int n,s, pi, t;
         ^