2013年8月8日

UVa 10978 - Let's Play Magic!

#include <cstdio>
#include <cstring>

int main() {
  int n;
  while (scanf("%d", &n) && n) {
    char v[99][99], ans[99][99] = {};
    int cnt = -1;
    for (int i = 0; i < n; i++) {
      scanf("%s", v[i]);
      char suit[99];
      scanf("%s", suit);
      int len = strlen(suit);
      while (len--) {
        cnt = (cnt + 1) % n;
        while (ans[cnt][0]) {
          cnt = (cnt + 1) % n;
        }
      }
      strcpy(ans[cnt], v[i]);
    }
    for (int i = 0; i < n; i++) {
      printf("%s%s", ans[i], i == n - 1 ? "\n" : " ");
    }
  }
  return 0;
}

沒有留言:

張貼留言