Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
就是四条边同时扩张就可以了#include <iostream> #include <cstdio> #include <string> #include <string.h> #include <vector> #include <cstdlib> #include <algorithm> #include <cmath> #include <queue> #include <set> #include <stack> #include <functional> #include <fstream> #include <sstream> #include <iomanip> #include <numeric> #include <cassert> #include <bitset> #include <stack> #include <ctime> #include <list> using namespace std; int map[70][70]; int main() { int m,n,i=1,j=1; scanf("%d%d",&m,&n); memset(map,0,sizeof(map)); int time=1; char c='A'; map[1][1]='A'; while(time<m*n) { while(j+1<=n && !map[i][j+1]) { if(c>=90) c-=26; map[i][++j]=++c; ++time; } while(i+1<=m && !map[i+1][j]) { if(c>=90) c-=26; map[++i][j]=++c; ++time; } while(j-1>=1 && !map[i][j-1]) { if(c>=90) c-=26; map[i][--j]=++c; ++time; } while(i-1>=1 && !map[i-1][j]) { if(c>=90) c-=26; map[--i][j]=++c; ++time; } } for(i=1; i<=m; i++) { for(j=1; j<=n; j++) printf(" %c",map[i][j]); printf("\n"); } return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator