Compile Error

/in/foo.cc: In function 'int main()':
/in/foo.cc:5:11: error: 'time' was not declared in this scope
    5 |     srand(time(0));
      |           ^~~~
/in/foo.cc:1:1: note: 'time' is defined in header '<ctime>'; did you forget to '#include <ctime>'?
  +++ |+#include <ctime>
    1 | using namespace std;
/in/foo.cc:5:5: error: 'srand' was not declared in this scope
    5 |     srand(time(0));
      |     ^~~~~
/in/foo.cc:8:22: error: 'rand' was not declared in this scope
    8 |     int random_num = rand();
      |                      ^~~~
/in/foo.cc:19:9: error: 'cout' was not declared in this scope
   19 |         cout<<ans<<endl;
      |         ^~~~
/in/foo.cc:1:1: note: 'std::cout' is defined in header '<iostream>'; did you forget to '#include <iostream>'?
  +++ |+#include <iostream>
    1 | using namespace std;
/in/foo.cc:19:15: error: 'ans' was not declared in this scope
   19 |         cout<<ans<<endl;
      |               ^~~
/in/foo.cc:19:20: error: 'endl' was not declared in this scope
   19 |         cout<<ans<<endl;
      |                    ^~~~
/in/foo.cc:1:1: note: 'std::endl' is defined in header '<ostream>'; did you forget to '#include <ostream>'?
  +++ |+#include <ostream>
    1 | using namespace std;
/in/foo.cc:8:9: warning: unused variable 'random_num' [-Wunused-variable]
    8 |     int random_num = rand();
      |         ^~~~~~~~~~

信息

递交者
类型
递交
题目
P2701 最后的王者 pta202311T4
语言
C++
递交时间
2026-10-31 21:20:21
评测时间
2026-10-31 21:20:21
评测机
分数
0
总耗时
0ms
峰值内存
0 Bytes