poj 3752 字母旋转游戏

poj 3752 字母旋转游戏,第1张

poj 3752 字母旋转游戏
#include <iostream>using namespace std;char map[10000][10000];int main(){    int i, j, m, n, tot;    char ch = 'A';    cin >> m >> n;    for(i = 0; i < m; i++)       for (j = 0; j < n; j++) map[i][j] = '0';    i = j = tot = 0;    map[i][j] = 'A';    while (tot < n*m-1){//注意这里的判断!while (j+1 < n && map[i][j+1] == '0'){     if (ch >= 90)  ch -= 26;     j = j + 1;     ch = ch + 1;     map[i][j] = ch;     tot = tot + 1;          }          while (i+1 < m && map[i+1][j] == '0'){     if (ch >= 90)  ch -= 26;     i = i + 1;     ch = ch + 1;     map[i][j] = ch;     tot = tot + 1;          }          while (j-1 >= 0 && map[i][j-1] == '0'){     if (ch >= 90)  ch -= 26;     j = j - 1;     ch = ch + 1;     map[i][j] = ch;     tot = tot + 1;          }          while (i-1 >= 0 && map[i-1][j] == '0'){     if (ch >= 90)  ch -= 26;     i = i - 1;     ch = ch + 1;     map[i][j] = ch;     tot = tot + 1;          }    }    for (i = 0; i < m; i++){       for (j = 0; j < n; j++) cout << "   " << map[i][j];       cout << endl;    }}

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

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

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

发表评论

登录后才能评论

评论列表(0条)

保存