-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathUntitled1.cpp
60 lines (56 loc) · 1.36 KB
/
Untitled1.cpp
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
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
int main() {
int t;
cin>>t;t++;
while(t--)
{
string s="";
int c=0;
getline(cin,s);
int a,b;
for(int i=0;i<s.length();i++)
{
if(s[i]==' ')
{
if(c==1)
b=i;
else
a=i;
c++;
}
else if(s[i]>=65 && s[i]<=90)
s[i]=s[i]+32;
}
string n="";
if(c==1){
n=s.substr(a+1);
n[0]= toupper(n[0]);
if(s[0]>=97 && s[0]<=122)
s[0]=s[0]-32;
string s1;
s1.push_back(s[0]);
n=s1+". "+n;
}
else if(c==2){
n=s.substr(b+1);
n[0]=toupper(n[0]);
string s1,s2;
if(s[0]>=97 && s[0]<=122)
s[0]=s[0]-32;
if(s[a+1]>=97 && s[a+1]<=122)
s[a+1]=s[a+1]-32;
s1.push_back(s[0]);
s2.push_back(s[a+1]);
n=s1+". "+s2+". "+n;
}
else{n=s;
n[0]=toupper(n[0]);
}
cout<<n<<"\n";
}
}