-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
29 lines (24 loc) · 1.13 KB
/
main.cpp
File metadata and controls
29 lines (24 loc) · 1.13 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
#include <iostream>
using namespace std;
#include "CircularInt.hpp"
int main() {
CircularInt hour {1, 12}; // <hour is an integer between 1 and 12, like an hour on the clock>
cout << hour << endl; // 1
hour += 4; cout << hour << endl; // 5
(hour += 2)++; cout << hour << endl; // 8
hour += 18; cout << hour << endl; // 2 (18 hours after 8)
cout << -hour << endl; // 10 (2 hours before midnight)
hour = 1 - hour; cout << hour << endl; // 11 (2 hours before 1)
cout << hour+hour << endl; // 10 (11 hours after 11)
hour *= 2; cout << hour << endl; // 10 (11*2 = 11+11)
cout << hour/2 << endl; // TWO OPTIONS: 11 (since 11*2=10) or 5 (since 5*2=10 too).
try {
cout << hour/3;
} catch (const string& message) {
cout << message << endl; // "There is no number x in {1,12} such that x*3=10"
}
// RIDDLES (not for submission):
// * when is there exactly one answer to a/b? prime
// * when are there two or more answers to a/b? non-prime
// * when is there no answer to a/b? b=0
}