CLCK @ 2022-09-11 21:05:21
如题
不知道为什么MLE
是不是字符串处理哪里有问题
求助 /kk
#include <iostream>
#include <algorithm>
using namespace std;
string s[10];
int n[10];
string ss[30] = {
"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 nn[30] = {
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
};
void read() {
while (1) {
int i = 0;
char x;
cin >> x;
if (x == '.' || x == '\n') break;
while (x != ' ' && x != '\n') {
s[i] += x;
}
i++;
}
return ;
}
void check() {
for (int i = 0; i < 6; i++) {
for (int j = 0; j < 30; j++) {
if (s[i] == ss[j]) {
n[i] = nn[j];
}
}
}
return ;
}
int main() {
read();
check();
for (int i = 0; i < 6; i++) {
n[i] *= n[i];
n[i] %= 100;
}
sort(n, n + 6);
for (int i = 0; i < 6; i++) {
if (n[i] < 10 && n[i] != 0) cout << '0';
if (n[i] != 0) cout << n[i];
}
cout << endl;
}
by CLCK @ 2022-09-11 21:05:54
忘记考虑大小写了
不过没关系 想先解决当务之急(
by xingcode @ 2022-11-27 14:37:53
#include<bits/stdc++.h>
using namespace std;
int s,l=1;
int t[10];
string a,b;
int main()
{
for(int i=1;i<=6;i++)
{
cin>>b;
if(b=="one"||b=="another"||b=="first"||b=="a")
{
t[l]=1;
l++;
}
else if(b=="two"||b=="both"||b=="second")
{
t[l]=4;
l++;
}
else if(b=="three"||b=="third")
{
t[l]=9;
l++;
}
else if(b=="four")
{
t[l]=16;
l++;
}
else if(b=="five")
{
t[l]=25;
l++;
}
else if(b=="six")
{
t[l]=36;
l++;
}
else if(b=="seven")
{
t[l]=49;
l++;
}
else if(b=="eight")
{
t[l]=64;
l++;
}
else if(b=="nine")
{
t[l]=81;
l++;
}
else if(b=="eleven")
{
t[l]=21;
l++;
}
else if(b=="twelve")
{
t[l]=44;
l++;
}
else if(b=="thirteen")
{
t[l]=69;
l++;
}
else if(b=="fourteen")
{
t[l]=96;
l++;
}
else if(b=="fifteen")
{
t[l]=25;
l++;
}
else if(b=="sixteen")
{
t[l]=56;
l++;
}
else if(b=="seventeen")
{
t[l]=89;
l++;
}
else if(b=="eighteen")
{
t[l]=24;
l++;
}
else if(b=="nineteen")
{
t[l]=61;
l++;
}
}
sort(t+1,t+l);
long long s=0;
for(int i=1;i<l;i++)
{
s=s*100+t[i];
}
cout<<s;
return 0;
}