-
Notifications
You must be signed in to change notification settings - Fork 37
Expand file tree
/
Copy path1110.cpp
More file actions
26 lines (23 loc) · 720 Bytes
/
1110.cpp
File metadata and controls
26 lines (23 loc) · 720 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#include <stdio.h>
#include <deque>
int main(){
int n, i;
while(1){
scanf("%d",&n);
if(n == 0) break;
std::deque<int> cartas;
for(i = 1; i <= n; i++){
cartas.push_back(i);
}
printf("Discarded cards: ");
while(cartas.size() > 1){
if(cartas.size() != 2) printf("%d, ", cartas.front());
else printf("%d\n", cartas.front());
cartas.pop_front();
cartas.push_back(cartas.front());
cartas.pop_front();
}
printf("Remaining card: %d\n",cartas.front());
}
return 0;
}