-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathday3.cpp
62 lines (46 loc) · 1.19 KB
/
day3.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
60
61
/*
* Tutorial: 30 Days of Code.
* A solution to "Day 3: Intro to Conditional Statements"
* Submitted by A. S. "Aleksey" Ahmann <[email protected]>
* Submitted on Feb. 19, 2024
* Link: https://www.hackerrank.com/challenges/30-conditional-statements/problem
*
* Task description:
*/
#include <bits/stdc++.h>
using namespace std;
string ltrim(const string &);
string rtrim(const string &);
int main()
{
string N_temp;
getline(cin, N_temp);
int N = stoi(ltrim(rtrim(N_temp)));
if (N % 2 != 0)
cout << "Weird" << endl;
else if (N % 2 == 0 && N >= 2 && N <= 5)
cout << "Not Weird" << endl;
else if (N % 2 == 0 && N >= 6 && N <= 20)
cout << "Weird" << endl;
else if (N % 2 == 0 && N >= 20)
cout << "Not Weird" << endl;
else
(void)0;
return 0;
}
string ltrim(const string &str) {
string s(str);
s.erase(
s.begin(),
find_if(s.begin(), s.end(), not1(ptr_fun<int, int>(isspace)))
);
return s;
}
string rtrim(const string &str) {
string s(str);
s.erase(
find_if(s.rbegin(), s.rend(), not1(ptr_fun<int, int>(isspace))).base(),
s.end()
);
return s;
}