Advertisement
cd62131

rewrite for C, only while loop

Oct 19th, 2013
235
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.94 KB | None | 0 0
  1. #include <stdio.h>
  2. int main(void) {
  3.     int H, W, m, n;
  4.     while (1) {
  5.         scanf("%d%d", &H, &W);
  6.         if (H == 0 || W == 0) { break; }
  7.         m = n = 1;
  8.         while (m <= H && n <= W) {
  9.             if (m == 1) {
  10.                 printf("#");
  11.                 if (n == W) { printf("\n"); n = 1; m++; }
  12.                 else { n++; }
  13.                 continue;
  14.             }
  15.             if (m == H) {
  16.                 printf("#");
  17.                 if (n == W) { printf("\n"); n = 1; m++; }
  18.                 else { n++; }
  19.                 continue;
  20.             }
  21.             if (n == 1) {
  22.                 printf("#");
  23.                 if (n == W) { printf("\n"); n = 1; m++; }
  24.                 else { n++; }
  25.                 continue;
  26.             }
  27.             if (n == W) {
  28.                 printf("#\n"); n = 1; m++; continue;
  29.             }
  30.             printf("."); n++;
  31.         }
  32.         printf("\n");
  33.     }
  34.     return 0;
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement