Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

代码

Posted by zhjou at 2014-05-06 22:02:21
#include <cstdlib>
#include <iostream>

using namespace std;

int main(int argc, char *argv[])
{
    int m,n,r=0;
    int cs=0;
    char a[64][64]={{0}};
    scanf("%d%d",&m,&n); 
    int num=0;
    while(num<n*m){
      switch(cs){
              case 0: 
                   for(int i=r;i<n-r;i++){
                          a[r][i]=(num++)%26+'A';
                          }
                          cs=1;
                     break;
              case 1: 
                   for(int i=r+1;i<m-r;i++){
                     a[i][n-r-1]=(num++)%26+'A';
                   }                              
                    cs=2;
                    break;
              case 2: 
                   for(int i=n-r-2;i>=r;i--){
                  a[m-r-1][i]=(num++)%26+'A';
                   }  
                   cs=3;
                   break;
              case 3:for(int i=m-r-2;i>r;i--){
                   a[i][r]=(num++)%26+'A';
                   }  
                   cs=0;r++;
                   break;
                   } 
              }   
    for(int i=0;i<m;i++)
        {
            for(int j=0;j<n;j++){
               printf("   %c",a[i][j]);
        }
         printf("\n");
         } 
    system("PAUSE");
    return EXIT_SUCCESS;
}

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator