-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy path131A.cpp
More file actions
38 lines (30 loc) · 775 Bytes
/
Copy path131A.cpp
File metadata and controls
38 lines (30 loc) · 775 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
37
38
#include <bits/stdc++.h>
#define FOR(i, start, end) for(int i = start; i < end; i++)
using namespace std;
typedef long long LL;
char toLower(char x) {
if (x >= 'A' && x <= 'Z')
return (x - 'A') + 'a';
return x;
}
char toUpper(char x) {
if (x >= 'a' && x <= 'z')
return (x - 'a') + 'A';
return x;
}
int main() {
string s;
cin >> s;
int len = s.length();
bool capsTrig = true;
for (int i = 0; i < len; i++) {
if ((i > 0) && s[i] >= 'a' && s[i] <= 'z')
capsTrig = false;
}
if (capsTrig) {
for (int i = 0; i < len; i++) {
printf("%c", (s[i] >= 'A' && s[i] <= 'Z') ? toLower(s[i]) : toUpper(s[i]));
}
} else printf("%s", s.c_str());
printf("\n");
}