-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path1601.cpp
More file actions
61 lines (58 loc) · 1.2 KB
/
1601.cpp
File metadata and controls
61 lines (58 loc) · 1.2 KB
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
#include <iostream>
#include <string>
#include <iomanip>
#include <cmath>
using namespace std;
char cap(char x) {
int z = x;
if ((z > 64) && (z < 91)) {
z += 32;
char c;
c = z;
return c;
}
return x;
}
char anticap(char x) {
int z = x;
if ((z > 96) && (z < 123)) {
z -= 32;
char c;
c = z;
return c;
}
return x;
}
bool SentEndKa(char z) {
if ((z == '.') || (z == '?') || (z == '!')) return 1;
else return 0;
}
bool IsChar(char z) {
if (((z > 64) && (z < 91)) || ((z > 96) && (z < 123))) return 1;
return 0;
}
int main() {
string s;
bool SentEnd = 1;
getline(cin, s);
while (s != "") {
string fixed = "";
for (int i = 0; i < size(s); i++) {
char curs = s[i];
if (SentEnd == 1) {
if (IsChar(curs)) {
fixed += anticap(curs);
SentEnd = 0;
}
else fixed += curs;
}
else {
fixed += cap(curs);
SentEnd = SentEndKa(curs);
}
}
cout << fixed << endl;
getline(cin, s);
}
return 0;
}