标签:
Time Limit: 1000MS | Memory Limit: 65536K | |
Total Submissions: 7890 | Accepted: 2983 |
Description
A B C D E F G H
V W X Y Z A B I
U J K L M N C J
T I H G F E D K
S R Q P O N M L
Input
Output
Sample Input
4 9
Sample Output
A B C D E F G H I V W X Y Z A B C J U J I H G F E D K T S R Q P O N M L
Source
分析:
模拟
1 #include<iostream> 2 #include<queue> 3 #include<cstdio> 4 #include<cstring> 5 #include<cmath> 6 using namespace std; 7 char map[1005][1005],c[26]={‘A‘,‘B‘,‘C‘,‘D‘,‘E‘,‘F‘,‘G‘,‘H‘,‘I‘,‘J‘,‘K‘,‘L‘,‘M‘,‘N‘,‘O‘,‘P‘,‘Q‘,‘R‘,‘S‘,‘T‘,‘U‘,‘V‘,‘W‘,‘X‘,‘Y‘,‘Z‘}; 8 int main(){ 9 int m,n; 10 cin>>m>>n; 11 int i,j,x=1,y=0; 12 memset(map,‘0‘,sizeof(map)); 13 int sum=m*n; 14 //cout<<m<<‘ ‘<<n<<endl; 15 i=0; 16 for(;i<sum;){ 17 while(y+1<=n&&map[x][y+1]==‘0‘){ 18 y++; 19 //cout<<"i: "<<i<<endl; 20 map[x][y]=c[i%26]; 21 i++; 22 } 23 // cout<<1<<endl; 24 while(x+1<=m&&map[x+1][y]==‘0‘){ 25 x++; 26 //i++; 27 //cout<<"i: "<<i<<endl; 28 map[x][y]=c[i%26]; 29 i++; 30 } 31 // cout<<2<<endl; 32 while(y-1>0&&map[x][y-1]==‘0‘){ 33 y--; 34 //i++; 35 // cout<<"i: "<<i<<endl; 36 map[x][y]=c[i%26]; 37 i++; 38 } 39 // cout<<3<<endl; 40 while(x-1>0&&map[x-1][y]==‘0‘){ 41 x--; 42 //i++; 43 // cout<<"i: "<<i<<endl; 44 map[x][y]=c[i%26]; 45 i++; 46 } 47 // cout<<4<<endl; 48 } 49 //cout<<m<<‘ ‘<<n<<endl; 50 for(i=1;i<=m;i++){ 51 for(j=1;j<=n;j++){ 52 cout<<" "<<map[i][j]; 53 //A B C D E F G H 54 } 55 cout<<endl; 56 } 57 return 0; 58 }
标签:
原文地址:http://www.cnblogs.com/Deribs4/p/4285123.html