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:20:9: error: 'cout' was not declared in this scope
   20 |         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:20:20: error: 'endl' was not declared in this scope
   20 |         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();
      |         ^~~~~~~~~~

信息

递交者
类型
递交
题目
P2924 古籍展架优化计划 pta202505T4
语言
C++
递交时间
2026-10-31 21:17:45
评测时间
2026-10-31 21:17:45
评测机
分数
0
总耗时
0ms
峰值内存
0 Bytes