-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathlab_function.cpp
More file actions
36 lines (30 loc) · 1.02 KB
/
lab_function.cpp
File metadata and controls
36 lines (30 loc) · 1.02 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
#include <vector>
#include <iostream>
#include <sstream>
#include <string>
#include <stdexcept>
using namespace std;
// COMPLETE ME
// PUT THE leap_year() FUNCTION THAT YOU WRITE HERE
int main()
{
int errors = 0;
for( int year=1800; year<2101; ++year )
{
// deliberate gibberish so that you can't just copy the answer
bool correctAnswer = (!(year%('b'+'e'+'c'+'f'))&&!(year%'d'))||(!(year&('R'-'O'/*+'Q'+'T'*/))&&(year%'d'))||(!(year%('d'+'d'+'d'+'d'))&&(year&('*'-'\''))&&(year%('N'-'\'')));
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++;
}
}
if( errors == 0 )
cout << "Congratulations, no errors" << endl;
else
cout << "Uh oh, " << errors << " error/s remain" << endl;
return errors;
}