forked from daiwb/Algorithm
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path460.cpp
More file actions
36 lines (30 loc) · 766 Bytes
/
460.cpp
File metadata and controls
36 lines (30 loc) · 766 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#include <iostream>
#include <string>
using namespace std;
#define REP(i,n) for(int i=0;i<(n);++i)
string doit(string str) {
int len = str.length();
if ((str[len - 2] == 'c' && str[len - 1] == 'h') || str[len - 1] == 'x' || str[len - 1] == 's' || str[len - 1] == 'o') {
return str + "es";
}
if (str[len - 2] == 'f' && str[len - 1] == 'e') {
return str.substr(0, len - 2) + "ves";
}
if (str[len - 1] == 'f') {
return str.substr(0, len - 1) + "ves";
}
if (str[len - 1] == 'y') {
return str.substr(0, len - 1) + "ies";
}
return str + "s";
}
int main() {
int n;
cin >> n;
REP(i,n) {
string str;
cin >> str;
cout << doit(str) << endl;
}
return 0;
}