-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path131A-cAPS lOCK.cpp
57 lines (43 loc) · 962 Bytes
/
131A-cAPS lOCK.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
#include <bits/stdc++.h>
using namespace std;
int main(){
string s;
cin >> s;
int count1 = 0;
int count2 = 0;
int sz = s.size();
for(int i = 1; i<sz;i++) // chekcing if char other than 0th position is non-capital or not
{
if(islower(s[i]))
{
count1++;
}
}
for(int i = 0; i<sz; i++)
{
if(isupper(s[i]))
{
count2++;
}
}
if(islower(s[0]) && count1==0) // if only 0th is non-capital && not any onther is capital
{
s[0] = toupper(s[0]);
for(int i = 1; i< sz; i++)
{
s[i] = tolower(s[i]);
}
}
else if(count2 == sz) // if every letter is capital
{
for(int i = 0; i<sz; i++)
{
s[i] = tolower(s[i]);
}
}
else
{
}
cout << s << endl;
return 0;
}