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 dut317410027 at 2010-05-23 19:15:57 on Problem 3752
#include <stdio.h>
#include <stdlib.h>
int a[10000][10000];
int main()
{
    int n,m,i,j,flag,k;
    while (scanf("%d%d",&n,&m)!=EOF)
    {
        k=65;
        if (n%2==0)
        {
            flag=n/2;
            for (i=0;i<flag;i++)
            {
                for (j=i;j<m-i;j++)
                {
                    a[i][j]=k;
                    k++;
                    if (k==91)
                    {
                        k=65;
                    }
                }
                for (j=i+1;j<n-i-1;j++)
                {
                    a[j][m-i-1]=k;
                    k++;
                    if (k==91)
                    {
                        k=65;
                    }

                }
                for (j=m-i-1;j>=i;j--)
                {
                    a[n-1-i][j]=k;
                    k++;
                    if (k==91)
                    {
                        k=65;
                    }
                }
                for (j=n-i-2;j>=i+1;j--)
                {
                    a[j][i]=k;
                    k++;
                    if (k==91)
                    {
                        k=65;
                    }
                }
            }
            for (i=0;i<n;i++)
            {
                for (j=0;j<m;j++)
                {
                    printf("   %c",a[i][j]);
                }
                printf("\n");
            }
        }
        else
        {
            flag=n/2+1;

            for (i=0;i<flag;i++)
            {
                for (j=i;j<m-i;j++)
                {
                    a[i][j]=k;
                    k++;
                    if (k==91)
                    {
                        k=65;
                    }
                }
                for (j=i+1;j<n-i-1;j++)
                {
                    a[j][m-i-1]=k;
                    k++;
                    if (k==91)
                    {
                        k=65;
                    }

                }

                if (i!=flag-1)
                    for (j=m-i-1;j>=i;j--)
                    {
                        a[n-1-i][j]=k;
                        k++;
                        if (k==91)
                        {
                            k=65;
                        }
                    }
                for (j=n-i-2;j>=i+1;j--)
                {
                    a[j][i]=k;
                    k++;
                    if (k==91)
                    {
                        k=65;
                    }
                }
            }
            for (i=0;i<n;i++)
            {
                for (j=0;j<m;j++)
                {
                    printf("   %c",a[i][j]);
                }
                printf("\n");
            }
        }
    }
    return 0;
}

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