第三个点过不了 求教

P1603 斯诺登的密码

ylsoi @ 2017-06-28 18:13:35

帮忙看一看啊,为什么会只有80分

#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<cmath>
bool pd(char a)
{
    if(a>='A'&&a<='Z')return true;
    return false;
}
int compare(int a,int b)
{
    if(a/10==0&&b/10!=0)return 1;
    if(a/10!=0&&b/10==0)return 0;
    if(a/10==0&&b/10==0)return a<b;
    if(a/10!=b/10)return a/10<b/10;
    if(a/10==b/10)return a%10<b%10;
}
using namespace std;
int main()
{
    int len,i,j,num[10]={0},k=0;
    char a[10][20];
    char b[30][20]={"\0","one","two","three","four","five","six","seven","eight","nine","ten","eleven","twelve","thirteen","fourteen","fifteen","sixteen","seventeen","eighteen","nineteen","twenty"};
    char c[10][20]={"\0","a","both","another"};
    char d[10][20]={"\0","first","second","third"};
    char str[100]="\0";
    memset(num,-1,sizeof(num));
    for(i=1;i<=6;i++)
    {
        scanf("%s",a[i]);
        for(j=0;j<=strlen(a[i])-1;j++)
        {
            if(pd(a[i][j]))a[i][j]=tolower(a[i][j]);
            if(a[i][j]=='.')a[i][j]='\0';
        }
    }
    for(i=1;i<=6;i++)
    {
        for(j=1;j<=20;j++)
        if(strcmp(a[i],b[j])==0)num[i]=j;
        for(j=1;j<=3;j++)
        if(strcmp(a[i],c[j])==0)num[i]=j;
        for(j=1;j<=3;j++)
        if(strcmp(a[i],d[j])==0)num[i]=j;
    }    
    for(i=1;i<=6;i++)
    if(num[i]!=-1)num[i]=num[i]*num[i]%100;
    sort(num+1,num+7,compare);
    for(i=1;i<=6;i++)
    if(num[i]>=0)break;
    for(j=i;j<=6;j++)
    {
        if(num[j]==0)
        {
            str[k]='0';
            k++;
            str[k]='0';
            k++;
        }
        else if(num[j]<10)
        {
            str[k]='0';
            k++;
            str[k]=num[j]+48;
            k++;
        }
        else
        {
            str[k]=num[j]/10+48;
            k++;
            str[k]=num[j]%10+48;
            k++;
        }
    }
    len=strlen(str);
    for(i=0;i<=len-1;i++)
    if(str[i]!='0')break;
    for(j=i;j<=len-1;j++)
    printf("%c",str[j]);
    return 0;
}

by KKarshilov @ 2017-07-05 12:48:18

第三个点没有数字


|