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

哭死 在你们北大上AC 在工大上就是不AC 郁闷中!!!!!!!!!!!!!!!!!!

Posted by huaixiaozi at 2008-01-17 14:01:44 on Problem 2612
#include <stdio.h>
#include <stdlib.h>

int main()
{
    char a[11][15];
    char b[11][15];
    int m,i,j,c,d,flag,count;

    while (scanf("%d",&m)!=EOF)
    {
        for (i=0;i<m;i++)
        {
            scanf("%s",a[i]);
        }
        for (i=0;i<m;i++)
        {
            scanf("%s",b[i]);
        }
        flag=0;
        for (i=0;i<m;i++)
        {
            for (j=0;j<m;j++)
            {
                if (b[i][j]=='x'&&a[i][j]=='*')
                {
                    flag=1;
                    goto exit;
                }
            }
        }
exit:
        ;
        if (flag==1)
        {
            for (i=0;i<m;i++)
            {
                for (j=0;j<m;j++)
                {
                    if (b[i][j]=='x'&&a[i][j]!='*')
                    {
                        count=0;
                        if (c==0)
                        {
                            for (c=i;c<=i+1;c++)
                            {
                                if (j==0)
                                {
                                    for (d=j;j<=j+1;j++)
                                    {
                                        if (a[c][d]=='*')
                                        {
                                            count++;
                                        }
                                    }
                                }
                                else
                                {
                                    for (d=j-1;j<=j+1;j++)
                                    {
                                        if (a[c][d]=='*')
                                        {
                                            count++;
                                        }
                                    }
                                }
                            }
                        }
                        else
                        {
                            for (c=i-1;c<=i+1;c++)
                            {
                                if (j==0)
                                {
                                    for (d=j;d<=j+1;d++)
                                    {
                                        if (a[c][d]=='*')
                                        {
                                            count++;
                                        }
                                    }
                                }
                                else
                                {
                                    for (d=j-1;d<=j+1;d++)
                                    {
                                        if (a[c][d]=='*')
                                        {
                                            count++;
                                        }
                                    }
                                }
                            }
                        }
                        printf("%d",count);
                    }
                    if (b[i][j]=='x'&&a[i][j]=='*')
                    {
                        printf("*");
                    }
                    if (b[i][j]=='.')
                    {
                        if (a[i][j]=='*')
                        {
                            printf("*");
                        }
                        else
                        {
                            printf(".");
                        }
                    }
                }
                printf("\n");
            }
            printf("\n");
        }
        else
        {
            for (i=0;i<m;i++)
            {
                for (j=0;j<m;j++)
                {
                    if (b[i][j]=='x')
                    {
                        count=0;
                        if (c==0)
                        {
                            for (c=i;c<=i+1;c++)
                            {
                                if (j==0)
                                {
                                    for (d=j;j<=j+1;j++)
                                    {
                                        if (a[c][d]=='*')
                                        {
                                            count++;
                                        }
                                    }
                                }
                                else
                                {
                                    for (d=j-1;j<=j+1;j++)
                                    {
                                        if (a[c][d]=='*')
                                        {
                                            count++;
                                        }
                                    }
                                }
                            }
                        }
                        else
                        {
                            for (c=i-1;c<=i+1;c++)
                            {
                                if (j==0)
                                {
                                    for (d=j;d<=j+1;d++)
                                    {
                                        if (a[c][d]=='*')
                                        {
                                            count++;
                                        }
                                    }
                                }
                                else
                                {
                                    for (d=j-1;d<=j+1;d++)
                                    {
                                        if (a[c][d]=='*')
                                        {
                                            count++;
                                        }
                                    }
                                }
                            }
                        }
                        printf("%d",count);
                    }
                    if (b[i][j]=='.')
                    {
                        printf(".");
                    }
                }
                printf("\n");
            }
            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