| ||||||||||
| 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 <cstdlib>
#include <iostream>
using namespace std;
int m,t,a[100][100];
int x,y,n,co;
void l1();
void l2();
void h1();
void h2();
void h1()
{
for(;y<t;y++)
{
if(a[x][y]!=-1) break;
a[x][y]=n;
n++;
n=n%26;
co++;
}if(co>=m*t) return;
y--;x++;
l1();
}
void h2()
{
for(;y>=0;y--)
{
if(a[x][y]!=-1) break;
a[x][y]=n;
n++;
n=n%26;
co++;
}if(co>=m*t) return;
y++;x--;
l2();
}
void l1()
{
for(;x<m;x++)
{
if(a[x][y]!=-1) break;
a[x][y]=n;
n++;
n=n%26;
co++;
}if(co>=m*t) return;
x--;y--;
h2();
}
void l2()
{
for(;x>=0;x--)
{
if(a[x][y]!=-1) break;
a[x][y]=n;
n++;
n=n%26;
co++;
}if(co>=m*t) return;
x++;y++;
h1();
}
int main(int argc, char *argv[])
{
while( cin>>m>>t)
{
for(int i=0;i<100;i++)
for(int j=0;j<100;j++)
a[i][j]=-1;
x=0;y=0;n=0;co=0;
h1();
for(int i=0;i<m;i++)
{
for(int j=0;j<t;j++)
cout<<" "<<char(a[i][j]+'A');
cout<<endl;
}
}
return EXIT_SUCCESS;
}
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator