标签:uva std names str discard for style iostream ini
直接模拟
1 #include <iostream> 2 using namespace std; 3 4 int cards[1000] ; 5 int main(int argc, char *argv[]) 6 { 7 int n; 8 while(cin >> n && n){ 9 for(int i=1;i<=n;i++) cards[i] = i ; 10 int h = 1,t = n,first=1 ; 11 cout<<"Discarded cards:"; 12 while(n >= 2){ 13 if(!first) printf(",") ; 14 printf(" %d",cards[h]) ; 15 h++ ; 16 cards[++t] = cards[h] ; 17 h ++ ; 18 n -- ; 19 first = 0; 20 } 21 printf("\nRemaining card: %d\n",cards[h]); 22 } 23 return 0; 24 }
卡片游戏 (Throwing card away I,UVa10935)
标签:uva std names str discard for style iostream ini
原文地址:https://www.cnblogs.com/secoding/p/9495844.html