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 youxirenjian163 at 2009-09-05 22:42:35 on Problem 1047
#include <iostream>
#include<cstring>
using namespace std;

int main()
{
    char ch[200];
    int i,j,k,n,m,x,y,z,a[180],l,b[180],num[10],num1[10];
    while(cin>>ch)
    {
        l=strlen(ch);
        for(i=0;i<=9;i++)
        {
            num[i]=0;
        }
        for(i=0;i<l;i++)
        {
            a[i]=ch[i]-48;
            num[a[i]]++;
        }
        m=0;
        for(i=2;i<=l;i++)
        {
            for(j=0;j<=9;j++)num1[j]=0;
            for(j=0;j<l;j++)
            {
                b[j]=0;
            }
            for(j=l-1;j>0;j--)
            {
                b[j]+=a[j]*i;
                b[j-1]+=b[j]/10;
                b[j]=b[j]%10;
            }
            b[0]=b[0]+a[0]*i;
            x=b[0]/10;
            if(x!=0)
            {
                num1[x]++;
            }
            b[0]=b[0]%10;
            for(j=0;j<l;j++)
            {
                num1[b[j]]++;
            }
            z=0;
            for(j=0;j<=9;j++)
            {
                if(num[j]!=num1[j])
                {
                    z=1;
                }
            }
            if(z==1)
            {
                m=1;
                cout<<ch<<ends<<"is not cyclic"<<endl;
                break;
            }
        }
        if(m==0)
        {
            cout<<ch<<" is cyclic"<<endl;
        }
    }
    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