xuan132 @ 2021-11-03 17:04:13
#include <stdio.h>
#include <string.h>
int main()
{
int n,i,j,c[10000]={0},h,v,t=0,q;
char a[10000],b[25][20]={"zero","one","two","three","four","five","six","seven","eight","night","ten","eleven","twelve","thirteen","fourteen","fifteen","sixteen","seventeen","eighteen","nineteen","twenty"};
for(j=0;j<6;j++)
{
scanf("%s",a);
n=strlen(a);
if(a[0]>='A'&&a[0]<='Z')
a[0]+=32;
if(a[n-1]=='.')
a[n-1]='\0',n--;
for(i=0;i<21;i++)
{
if(strcmp(a,b[i])==0)
{
h=((i)*(i))%100;
if(h!=0) c[q++]=h;
}
}
if(strcmp(a,"first")==0)
{
h=((1)*(1))%100;
if(h!=0) c[q++]=h;
}
else if(strcmp(a,"a")==0)
{
h=((1)*(1))%100;
if(h!=0) c[q++]=h;
}
else if(strcmp(a,"another")==0)
{
h=((1)*(1))%100;
if(h!=0) c[q++]=h;
}
else if(strcmp(a,"both")==0)
{
h=((2)*(2))%100;
if(h!=0) c[q++]=h;
}
else if(strcmp(a,"second")==0)
{
h=((2)*(2))%100;
if(h!=0) c[q++]=h;
}
else if(strcmp(a,"third")==0)
{
h=((3)*(3))%100;
if(h!=0) c[q++]=h;
}
}
if(q==0)
printf("0");
else
{
for(i=0;i<q-1;i++)
for(v=0;v<q-1;v++)
{
if(c[v]==0)
t++;
if(c[v]>c[v+1])
{
int tem=c[v];
c[v]=c[v+1];
c[v+1]=tem;
}
}
for(i=t;i<q;i++)
{
if(i==0+t)
printf("%d",c[i]);
else
printf("%02d",c[i]);
}
}
return 0;
}
by xuan132 @ 2021-11-03 17:31:46
改了long long,accept了
by xuan132 @ 2021-11-03 17:34:05
但我想知道为啥用longlong
by WangDebao @ 2022-02-20 16:24:49
@xuan132 假设当6个单词都是nine的时候,数字将变为6个81,排列后是一个12位的整数超过int的范围