fork(6) download
  1. #include <iostream>
  2. #include <string>
  3. using namespace std;
  4. #define SIZE 1000000000
  5.  
  6. struct stack {
  7. unsigned long long storage[SIZE];
  8. int cursor = 0;
  9. void push (int n) {
  10. storage[cursor] = n;
  11. cursor++;
  12. }
  13. int pop () {
  14. return storage[--cursor];
  15. }
  16. int back () {
  17. return storage[cursor-1];
  18. }
  19. unsigned int size () {
  20. return cursor;
  21. }
  22.  
  23. };
  24. int main () {
  25. stack s;
  26. string str;
  27. int n;
  28. int Q;
  29. cin >> Q;
  30. for(int i = 0; i < Q; i++)) {
  31. if (str == "PUSH") {
  32. cin >> n;
  33. s.push(n);
  34. cout << "ok" << endl;
  35. }
  36. else if (str == "POP") cout << s.pop() << endl;
  37. else if (str == "WHAT") cout << s.size() << endl;
  38.  
  39. }
  40. return 0;
  41. }
Compilation error #stdin compilation error #stdout 0s 3468KB
stdin
5
PUSH 5
PUSH 3
WHAT
POP
WHAT
compilation info
prog.cpp:7:33: error: size of array 'storage' is too large
  unsigned long long storage[SIZE];
                                 ^
prog.cpp: In member function 'void stack::push(int)':
prog.cpp:10:3: error: 'storage' was not declared in this scope
   storage[cursor] = n;
   ^
prog.cpp: In member function 'int stack::pop()':
prog.cpp:14:10: error: 'storage' was not declared in this scope
   return storage[--cursor];
          ^
prog.cpp: In member function 'int stack::back()':
prog.cpp:17:10: error: 'storage' was not declared in this scope
   return storage[cursor-1];
          ^
prog.cpp: In function 'int main()':
prog.cpp:30:28: error: expected primary-expression before ')' token
  for(int i = 0; i < Q; i++)) {
                            ^
stdout
Standard output is empty