#include <cstdio> #include <algorithm> int main() { int n; scanf("%d", &n); getchar(); while (n--) { char s[1000]; gets(s); int l, nS[1000]; for (l = 0; s[l]; l++) if (s[l] >= 'a') nS[l] = (s[l] - 'a') * 2 + 1; else nS[l] = (s[l] - 'A') * 2; std::sort(nS, nS + l); do { for (l = 0; s[l]; l++) if (nS[l] % 2 == 0) putchar(nS[l] / 2 + 'A'); else putchar(nS[l] / 2 + 'a'); puts(""); } while (std::next_permutation(nS, nS + l)); } 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題目程式碼)
2012年9月13日
UVa 195 - Anagram
訂閱:
張貼留言 (Atom)
沒有留言:
張貼留言