求助,为啥只有第三个过了!!!!!!!!

P1603 斯诺登的密码

哎呦不错 @ 2019-12-07 01:50:06

    #include<stdio.h>
    #include<string.h>
    #include<stdlib.h>
    int cmp(const void*a,const void*b)
    {
    return *(int*)a-*(int*)b;
    }
    long long ans;
    int main ()
    { 
    char c[30][15]={"zero","one","two","three","four","five","six","seven","eight","nine","ten","eleven","twelve", "thirteen", "fourteen", "fifteen", "sixteen", "seventeen", "eighteen", "nineteen", "twenty","a","both","another","first","second","third"};
    int num[30]={0,1,4,9,16,25,36,49,64,81,00,21,44,69,96,25,56,89,24,61,0,1,4,1,1,4,9};
    int a[10];
    int k=0,nums=0;
    char p[15];
    for(int i=0;i<6;i++)
    {
        scanf("%s",&p);
        for(k=0;k<30;k++)
        {
            if(!strcmp(p,c[k]))
            {
                a[nums]=num[k];
                nums++;
                break;
            }
        }
    }
    qsort(a,10,sizeof(a[0]),cmp);
    for(int j=0;j<nums;j++)
    {
        ans=ans*100;
        ans=ans+a[j];
    }
    printf("%lld",ans);
    return 0;
}

|