#include <cstdio> #include <cstring> #include <sstream> using namespace std; char value[13][9] = {"2", "3", "4", "5", "6", "7", "8", "9", "10", "Jack", "Queen", "King", "Ace"}; char suit[4][9] = {"Clubs", "Diamonds", "Hearts", "Spades"}; int main() { char s[999]; gets(s); int T; sscanf(s, "%d", &T); gets(s); while (T--) { gets(s); int n, shuffle[100][52]; sscanf(s, "%d", &n); for (int i = 0; i < n; i++) { int index = 0; while (index < 52) { gets(s); istringstream ss(s); while (ss >> shuffle[i][index]) { index++; } } } int now[52]; for (int i = 0; i < 52; i++) { now[i] = i; } while (gets(s) && s[0]) { int type; sscanf(s, "%d", &type); int next[52]; for (int i = 0; i < 52; i++) { next[i] = now[shuffle[type - 1][i] - 1]; } memcpy(now, next, sizeof(next)); } for (int i = 0; i < 52; i++) { printf("%s of %s\n", value[now[i] % 13], suit[now[i] / 13]); } if (T) { puts(""); } } return 0; }
Hello, I am a CS student from Taiwan.
I am learing English and Programming.
I'll save source code of some problems or small programs without comments in this blog.
I would recommend you not to read solution from others before you solved the problem.
(這邊專門存放沒有任何註解的小程式/OJ題目程式碼)
2013年8月28日
UVa 10205 - Stack 'em Up
訂閱:
張貼留言 (Atom)
沒有留言:
張貼留言