dazhuvss @ 2021-12-24 11:39:48
#include <bits/stdc++.h>
using namespace std;
int a[6], top, flag;
int main() {
int i = 0;
string ss[27] = {"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 dic[27] = {0, 1, 4, 9, 16, 25, 36, 49, 64, 81, 0, 21, 44, 69,
96, 25, 56, 89, 24, 61, 0, 1, 4, 1, 1, 4, 9};
string s;
while (i++ < 7) { // 6个单词加一个句号
cin >> s;
for (i = 0; i < 27; i++) {
if (s == ss[i]) {
a[top++] = dic[i];
}
}
}
sort(a, a + top);
for (i = 0; i < top; i++) {
if (flag == 0) {
if (a[i] != 0) {
printf("%d", a[i]);
flag = 1;
}
}
else
printf("%02d", a[i]);
}
if (flag == 0)
printf("0");
return 0;
}
by FanSizhe127 @ 2022-03-20 09:51:09
看不懂你的,看看我的吧```cpp
using namespace std;
string q[20]={"one","two","three","four","five","six","seven","eight","nine","ten","eleven","twelve","thirteen","fourteen","fifteen","sixteen","seventeen","eighteen","nineteen","twenty"};
int main()
{
string s[7];
int i,j,k=0,a[10005],f;
for(i=1;i<=6;i++)
{
cin>>s[i];
if(s[i]=="a"||s[i]=="first"||s[i]=="another")
{
k++;a[k]=1;
continue;
}
if(s[i]=="both"||s[i]=="second")
{
k++;a[k]=4;
continue;
}
if(s[i]=="third")
{
k++;a[k]=9;
continue;
}
for(j=0;j<20;j++)
{
if(s[i]==q[j])
{
k++;
a[k]=((j+1)*(j+1))%100;
break;
}
}
}
sort(a+1,a+k+1);
for(i=1;i<=k;i++)
{
if(i!=1)
if(a[i]<=9)cout<<0;
cout<<a[i];
}
if(k==0)
cout<<'0';
}
by FanSizhe127 @ 2022-03-20 09:51:30
#include<bits/stdc++.h>
using namespace std;
string q[20]={"one","two","three","four","five","six","seven","eight","nine","ten","eleven","twelve","thirteen","fourteen","fifteen","sixteen","seventeen","eighteen","nineteen","twenty"};
int main()
{
string s[7];
int i,j,k=0,a[10005],f;
for(i=1;i<=6;i++)
{
cin>>s[i];
if(s[i]=="a"||s[i]=="first"||s[i]=="another")
{
k++;a[k]=1;
continue;
}
if(s[i]=="both"||s[i]=="second")
{
k++;a[k]=4;
continue;
}
if(s[i]=="third")
{
k++;a[k]=9;
continue;
}
for(j=0;j<20;j++)
{
if(s[i]==q[j])
{
k++;
a[k]=((j+1)*(j+1))%100;
break;
}
}
}
sort(a+1,a+k+1);
for(i=1;i<=k;i++)
{
if(i!=1)
if(a[i]<=9)cout<<0;
cout<<a[i];
}
if(k==0)
cout<<'0';
}