Make_Shit_Code @ 2024-06-12 21:25:49
#include <bits/stdc++.h>
using namespace std;
char c[50][50]={"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 va[50]={0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,1,2,1,1,2,3};//µ¥´Ê¶ÔÓ¦µÄÖµ
int main()
{
string s;
getline(cin,s);
for(int i=0;i<s.size();i++)
if(s[i]>='A'&&s[i]<='Z')s[i]+=32;
string v[50];
int k=0;
for(int i=0;s[i]!='.';i++)//ÒÔ¿Õ¸ñΪ¼ä¾à·Ö¸î×Ö·û´®
{
if(s[i]==' ')
{k++;continue;
}
v[k].push_back(s[i]);
}
string ans[50];//´æ´¢µ¥´Ê±äÊý×ÖµÄ×Ö·û´®
int t=0;
for(int i=0;i<k;i++)//½«Ó¢Îĵ¥´Ê±ä³ÉÊý×Ö£¨Æ½·½ÔÙmod100£¬Ç°Öò¹³ä0£©
{
for(int j=0;j<=26;j++)
{
if(v[i].compare(c[j])==0){
char tmp[100];
int val=(va[j]*va[j])%100;
sprintf(tmp,"%d",val);
if(val<10){//²¹³ä0
tmp[1]=tmp[0];
tmp[0]='0';
}
ans[t]=tmp;
t++;
}
}
}
for(int i=0;i<t;i++)//½«×Ö·û´®ÉýÐò
{
for(int j=i;j<t;j++)
{
if(ans[i].compare(ans[j])==1)
swap(ans[i],ans[j]);
}
}
if(ans[0].size()==0)cout<<0;
else{
int fl=0;
for(int i=0;i<t;i++)
{
for(int j=0;j<ans[i].size();j++)
{
if(ans[i][j]=='0'&&fl==0)continue;
else fl=1;
cout<<ans[i][j];
}
}}
}
by Make_Shit_Code @ 2024-06-12 21:26:17
测点1本地也可以过,但是测评机过不了