2012年11月30日

UVa 11074 - Draw Grid


#include <stdio.h>

char map[1000][1000];

int main() {
  int s, t, n, test = 1;
  while (scanf("%d%d%d", &s, &t, &n) && s) {
    printf("Case %d:\n", test++);
    int r, c, l = s * n + t * (n + 1);
    for (r = 1; r <= l; r++) {
      for (c = 1; c <= l; c++)
        map[r][c] = '*';
      map[r][c] = 0;
    }
    int sr, sc;
    for (sr = t + 1; sr < l; sr += s + t)
      for (sc = t + 1; sc < l; sc += s + t) {
        int er, ec;
        for (er = sr; er < sr + s; er++)
          for (ec = sc; ec < sc + s; ec++)
            map[er][ec] = '.';
      }
    for (r = 1; r <= l; r++)
      puts(map[r] + 1);
    puts("");
  }
  return 0;
}

沒有留言:

張貼留言