yige_ @ 2019-04-20 17:37:10
本地freopen输出没问题啊……
#include<bits/stdc++.h>
using namespace std;
char ch[21][10]= {"zero","one","two","three","four","five","six","seven","eight","nine","ten","eleven","twelve","thirteen","fourteen","fifteen","sixteen","seventeen","eighteen","nineteen","twenty"};
int main()
{
char sentence[6][105],numChar[6][2];
int numInt[6]= { },n=0;
for(int i=0; i<=5; i++)
{
cin>>sentence[i];
for(int j=0; j<=20; j++)
if (strcmp(sentence[i],ch[j])==0)
{
numInt[n]=j*j%100;
if(numInt[n]>=0&&numInt[n]<=9)
numChar[n][0]='0',numChar[n][1]=numInt[n]+48;
else
numChar[n][1]=(numInt[n]%10)+48;
numChar[n][0]=((numInt[n]/10)%10)+48;
n++;
}
else
{
if(strcmp(sentence[i],"a")==0||strcmp(sentence[i],"first")==0)numInt[i]=1*1%100;
if(strcmp(sentence[i],"both")==0||strcmp(sentence[i],"another")==0||strcmp(sentence[i],"second")==0)numInt[i]=2*2%100;
if(strcmp(sentence[i],"third")==0)numInt[i]=3*3%100;
}
}
for(int i=0; i<n; i++)
for(int j=0; j<=n-i; j++)
if(strcmp(numChar[j],numChar[j+1])>0)swap(numChar[j],numChar[j+1]);
bool sign=0;
for(int i=0; i<n; i++)
{
if(numChar[i][0]=='0'&&numChar[i][1]=='0')continue;
else if(numChar[i][0]=='0'&&numChar[i][1]!='0'&&sign==0)
{
sign=1;
cout<<numChar[i][1];
continue;
}
else
cout<<numChar[i][0]<<numChar[i][1];
}
return 0;
}
by yige_ @ 2019-04-20 19:09:37
我忘输出0了……
by yige_ @ 2019-04-20 19:09:46
@yige_ 没事了