-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcamelcase4.txt
85 lines (74 loc) · 1.84 KB
/
camelcase4.txt
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
#include<bits/stdc++.h>
using namespace std;
int main()
{
string wrd,output;
while(getline(cin,wrd))
{
wrd.erase(remove(wrd.begin(), wrd.end(), '\r'), wrd.end());
output="";
char opr=wrd[0],typ=wrd[2];
for(int i=4;i<wrd.size();i++){
//TODO for combine operation
if(wrd[0]=='C')
{
if(i==4 && typ=='C')
{
output+=toupper(wrd[i]);
continue;
}
if(wrd[i]==' ')
{
continue;
}
if(wrd[i-1]==' ' && i!=4)
{
output+=toupper(wrd[i]);
continue;
}
output+=wrd[i];
}
//for split operation
else{
if(isupper(wrd[i]) && i!=4)
{
output+=' ';
output+=tolower(wrd[i]);
continue;
}
if(wrd[i]=='(')
{
break;
}
if(isupper(wrd[i]) && i==4)
{
output+=tolower(wrd[i]);
continue;
}
output+=wrd[i];
}
}
if(opr=='C' && typ=='M')
{
cout<<output+"()"<<endl;
}
else
{
cout<<output<<endl;
}
}
return 0;
}
// output:
// C;M;white sheet of paper
// whiteSheetOfPaper()
// S;V;pictureFrame
// picture frame
// S;M;plasticCup()
// plastic cup
// C;V;mobile phone
// mobilePhone
// C;C;coffee machine
// CoffeeMachine
// S;C;LargeSoftwareBook
// large software book