zoj 3109 Decode Message

zoj 3109 Decode Message,第1张

zoj 3109 Decode Message
#include<stdio.h>int main(){    int r, c;    char a[20][20];    while (scanf("%d %d", &r, &c), r && c)    {        getchar();        int i, j, index = 0;        for (i = 0; i < r; i++) for (j = 0; j < c; j++)     a[i][j] = getchar();        getchar();        int isRow = 1, isOrder = 1, rb = 0, re = c - 1, cb = 0, ce = r - 1;        while (1)        { if (isRow) {     if (rb > re)         break;     if (isOrder)     {         for (i = rb; i <= re; i++)  putchar(a[index][i] - 7);         index = re;         cb++;     }     else     {         for (i = re; i >= rb; i--)  putchar(a[index][i] - 7);         index = rb;         ce--;     }     isRow = !isRow; } else {     if (cb > ce)         break;     if (isOrder)     {         for (i = cb; i <= ce; i++)  putchar(a[i][index] - 7);         index = ce;         re--;     }     else     {         for (i = ce; i >= cb; i--)  putchar(a[i][index] - 7);         index = cb;         rb++;     }     isOrder = !isOrder;     isRow = !isRow; }        }        putchar('n');    }    return 0;}

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/zaji/4889470.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-11-12
下一篇 2022-11-12

发表评论

登录后才能评论

评论列表(0条)

保存