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 hanjiangtao at 2014-08-08 16:43:42 on Problem 1590
#include<stdio.h>
#include<string.h>
int main()
{
    char a[1000];
    int i, n, w, k;
    while( scanf("%s",&a)!=EOF )
    {
        n = strlen(a);
        k=0;
        w=0;
        for(i = 0; i < n/2; i++)
        {
            if(a[i] == 'B' || a[i] == 'C' || a[i] == 'D' || a[i] == 'F' || a[i] == 'G' || a[i] == 'K' || a[i] == 'N' || a[i] == 'P' || a[i] == 'Q' || a[i] == 'R' || a[i] == '4' || a[i] == '7' || a[i] == '9')
            {
                w=1;
                break;
            }
            else if(a[i] == 'E')
            {
                if(a[n-1-i] != '3')
                {
                    w = 1;
                    break;
                }
            }
            else if(a[i] == '3')
            {
                if(a[n-1-i] != 'E')
                {
                    w = 1;
                    break;
                }
            }
            else if(a[i] == 'J')
            {
                if(a[n-1-i] != 'L')
                {
                    w = 1;
                    break;
                }
            }
            else if(a[i] == 'L')
            {
                if(a[n-1-i] != 'J')
                {
                    w = 1;
                    break;
                }
            }
            else if(a[i] == 'S')
            {
                if(a[n-1-i] != '2')
                {
                    w = 1;
                    break;
                }
            }
            else if(a[i] == '2')
            {
                if(a[n-1-i] != 'S')
                {
                    w = 1;
                    break;
                }
            }
            else if(a[i] == 'Z')
            {
                if(a[n-1-i] != '5')
                {
                    w = 1;
                    break;
                }
            }
            else if(a[i] == '5')
            {
                if(a[n-1-i] != 'Z')
                {
                    w = 1;
                    break;
                }

            }
            else if(a[i] == '0')
            {
                if(a[n-1-i] != 'O')
                {
                    w = 1;
                    break;
                }
            }
            else if(a[i] == 'O')
            {
                if(a[n-1-i] != '0')
                {
                    w = 1;
                    break;
                }
            }
        }
        //判断是否为镜像串   如果是镜像w=0, 不是w=1;

        for(i = 0; i < n/2; i++)
        {
            if(a[i]=='0'&&a[n-1-i]=='O')
                break;
            else if(a[i]=='O'&&a[n-1-i]=='0')
                break;
            else if(a[i] != a[n-1-i])
            {
                k=1;
                break;
            }

        }


        //判断回文  如果是回文k=0;不是k=1;
        if(k==1&&w==1)
            printf("%s -- is not a palindrome.\n\n",a);
        else if(k==0&&w==1)
            printf("%s -- is a regular palindrome.\n\n",a);
        else if(k==1&&w==0)
            printf("%s -- is a mirrored string.\n\n",a);
        else if(k==0&&w==0)
            printf("%s -- is a mirrored palindrome.\n\n",a);
    }
    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