prog.cpp:2:5: error: cannot declare ‘::main’ to be a global variable
int main
^~~~
prog.cpp:5:5: error: expected primary-expression before ‘int’
int a = 1, b = 2, c;
^~~
prog.cpp:5:5: error: expected ‘}’ before ‘int’
prog.cpp:3:1: note: to match this ‘{’
{
^
prog.cpp:6:5: error: ‘c’ does not name a type
c = (a = 5, b = 10); // 先计算a = 5,再计算b = 10,整个逗号表达式的值是b = 10的值,即10
^
prog.cpp:7:10: error: ‘cout’ in namespace ‘std’ does not name a type
std::cout << "a的值: " << a << ", b的值: " << b << ", c的值: " << c << std::endl;
^~~~
In file included from prog.cpp:1:
/usr/include/c++/8/iostream:61:18: note: ‘std::cout’ declared here
extern ostream cout; /// Linked to standard output
^~~~
prog.cpp:10:5: error: expected unqualified-id before ‘for’
for (int i = 0, j = 5; i < 3 && j > 2; i++, j--) {
^~~
prog.cpp:10:28: error: ‘i’ does not name a type
for (int i = 0, j = 5; i < 3 && j > 2; i++, j--) {
^
prog.cpp:10:44: error: ‘i’ does not name a type
for (int i = 0, j = 5; i < 3 && j > 2; i++, j--) {
^
prog.cpp:16:10: error: ‘cout’ in namespace ‘std’ does not name a type
std::cout << "取最大值的结果: " << result << std::endl;
^~~~
In file included from prog.cpp:1:
/usr/include/c++/8/iostream:61:18: note: ‘std::cout’ declared here
extern ostream cout; /// Linked to standard output
^~~~
prog.cpp:18:5: error: expected unqualified-id before ‘return’
return 0;
^~~~~~
prog.cpp:19:1: error: expected declaration before ‘}’ token
}
^