-
Notifications
You must be signed in to change notification settings - Fork 1
/
UVA 10945 Mother bear.cpp
38 lines (36 loc) · 1.07 KB
/
UVA 10945 Mother bear.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
#include <iostream>
#include <cstdlib>
#include <cstring>
#include <fstream>
#include <string>
using namespace std;
int main()
{
//std::cout << "Hello World!\n";
string str;
getline(cin, str);
while (str != "DONE")
{
int l = 0, r = str.length() - 1;
while (l <= r) {
if (str[l] == ',' || str[l] == '.' || str[l] == '!' || str[l] == '?' || str[l] == ' ') {
l++;
continue;
}
if (str[r] == ',' || str[r] == '.' || str[r] == '!' || str[r] == '?' || str[r] == ' ') {
r--;
continue;
}
char a = (str[l] > 'Z') ? str[l] - 'a' + 'A' : str[l];
char b = (str[r] > 'Z') ? str[r] - 'a' + 'A' : str[r];
if (a != b) break;
l++;
r--;
}
//std::cout << l << ":" << r << std::endl;
if (l >= r) std::cout << "You won't be eaten!" << std::endl;
else std::cout << "Uh oh.." << std::endl;
getline(cin, str);
}
return 0;
}