Run ID 作者 问题 语言 测评结果 Time Memory 代码长度 提交时间
149763 练明一 简单的分支结构 C++ Compile Error 0 MS 0 KB 248 2026-03-16 17:03:21

Tests(0/0):


Code:

#include <iostream> using namespace std; int main(){ int x; cin>>x; if(x>0){ cout<<"1"; }else if(x<0){ cout<<"-1"; }else{ cout<<"0"; } }


Run Info:

Main.cc:1:21: warning: extra tokens at end of #include directive
 #include  using namespace std; 
                     ^
Main.cc: In function 'int main()':
Main.cc:3:12: error: 'cin' was not declared in this scope
     int x; cin>>x;
            ^
Main.cc:3:12: note: suggested alternative:
In file included from Main.cc:1:0:
/usr/include/c++/5/iostream:60:18: note:   'std::cin'
   extern istream cin;  /// Linked to standard input
                  ^
Main.cc:4:21: error: 'cout' was not declared in this scope
            if(x>0){ cout<<"1";
                     ^
Main.cc:4:21: note: suggested alternative:
In file included from Main.cc:1:0:
/usr/include/c++/5/iostream:61:18: note:   'std::cout'
   extern ostream cout;  /// Linked to standard output
                  ^
Main.cc:5:34: error: 'cout' was not declared in this scope
                   }else if(x<0){ cout<<"-1"; 
                                  ^
Main.cc:5:34: note: suggested alternative:
In file included from Main.cc:1:0:
/usr/include/c++/5/iostream:61:18: note:   'std::cout'
   extern ostream cout;  /// Linked to standard output
                  ^
Main.cc:6:39: error: 'cout' was not declared in this scope
                                }else{ cout<<"0"; 
                                       ^
Main.cc:6:39: note: suggested alternative:
In file included from Main.cc:1:0:
/usr/include/c++/5/iostream:61:18: note:   'std::cout'
   extern ostream cout;  /// Linked to standard output
                  ^