第一个点样例过不去其他4个都过了

P1603 斯诺登的密码

Alkri @ 2017-09-02 22:47:31

第一个点样例写Too long on line 0?

第一个点样例写Too long on line 0?

第一个点样例写Too long on line 0?

第一个点样例写Too long on line 0?

第一个点样例写Too long on line 0?

自己手lu样例都没有问题,没多空格没多行,完全跟testdata.out里面一样啊。。。

代码↓

#include <ctype.h>
#include <stdio.h>
#include <string.h>
#include <iostream>
#include <algorithm>
using namespace std;
const char data[27][101]={"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"};

const char mod[27][101]={"00","01","04","09","16","25","36","49","64","81","00","21","44","69","96","25","56","89","24","61",

                        "00","01","04","01","01","04","09"};
string word;
char w[7][101],cl[7][101];
int i,j,f;
bool nf=true;
int main()
{
    ios::sync_with_stdio(false);
    for (i=1; i<=6; i++) {scanf("%s",w[i]); w[i][0]=tolower(w[i][0]);}
    for (i=1; i<=6; i++)
        for (j=0; j<=26; j++)
            if (strcmp(w[i],data[j])==0) {f++; strcpy(cl[f],mod[j]);}
    for (i=1; i<=f; i++)
        for (j=i+1; j<=f; j++)
            if (strcmp(cl[i],cl[j])==1) swap(cl[i],cl[j]);
    for (i=1; i<=f; i++)
    {
        for (j=0; j<=1; j++)
            if (cl[i][j]=='0'&&nf) continue;
            else {cout<<cl[i][j]; nf=false;}
    }
    if (nf) cout<<"0"<<endl;
    return 0;
}

by codesonic @ 2017-10-04 21:23:48

如果使用了ios::sync_with_stdio(false);,不要用scanf或printf


|