-
Notifications
You must be signed in to change notification settings - Fork 14
Expand file tree
/
Copy pathlab_leap.cpp
More file actions
57 lines (32 loc) · 974 Bytes
/
lab_leap.cpp
File metadata and controls
57 lines (32 loc) · 974 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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#include <iostream>
using namespace std;
bool leap_year( int year )
{
// COMPLETE ME
return false;
}
int main()
{
int errors = 0;
for( int year=1800; year<2101; year++ )
{
// deliberate gibberish so you can't just copy the answer.
bool correctAnswer = year%(0xcb8+4136-0x1b50)==(0x943+3219-0x15d6)||(year%(0xba5+2053-0x13a6)==(0x9dd+6591-0x239c)&&year%(0x197c+1645-0x1f85)!=(0x18a9+3620-0x26cd));
bool yourAnswer = leap_year( year );
if( correctAnswer != yourAnswer )
{
cerr << "Error! leap_year() says " << year << (yourAnswer ? "is" : "is not") <<
" a leap year but it " << (correctAnswer ? "is" : "is not") << endl;
errors += 1;
}
}
if( errors == 0 )
{
cout << "Congratulations, no errors" << endl;
}
else
{
cout << "Uh oh, " << errors << " error/s remain" << endl;
}
return errors;
}