fork(5) download
  1. #include<cstdio>
  2. #include<queue>
  3. using namespace std;
  4. int main(){
  5. int t;
  6. scanf("%d",&t);
  7. while(t!=0){
  8. queue<int> q,q2;
  9. for(int i=1;i<=t;i++){
  10. q.push(i);
  11. }
  12. while(q.size()>0){
  13. q2.push(q.front);
  14. q.pop();
  15. q.push(q.front);
  16. q.pop();
  17. }
  18. printf("Discarded cards: ");
  19. while(q2.size()>2){
  20. printf("%d, ",q2.front());
  21. q2.pop();
  22. }
  23. printf("%d\n",q2.front());
  24. q2.pop();
  25. printf("Remaining card: %d\n",q2.front());
  26. scanf("%d",&t);
  27. }
  28. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
1
8
11
13
22
27
36
39
44
47
50
0
compilation info
prog.cpp: In function 'int main()':
prog.cpp:13: error: no matching function for call to 'std::queue<int, std::deque<int, std::allocator<int> > >::push(<unresolved overloaded function type>)'
/usr/include/c++/4.3/bits/stl_queue.h:225: note: candidates are: void std::queue<_Tp, _Sequence>::push(const typename _Sequence::value_type&) [with _Tp = int, _Sequence = std::deque<int, std::allocator<int> >]
prog.cpp:15: error: no matching function for call to 'std::queue<int, std::deque<int, std::allocator<int> > >::push(<unresolved overloaded function type>)'
/usr/include/c++/4.3/bits/stl_queue.h:225: note: candidates are: void std::queue<_Tp, _Sequence>::push(const typename _Sequence::value_type&) [with _Tp = int, _Sequence = std::deque<int, std::allocator<int> >]
stdout
Standard output is empty