-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcodingbat.cpp
More file actions
96 lines (81 loc) · 1.63 KB
/
codingbat.cpp
File metadata and controls
96 lines (81 loc) · 1.63 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
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
// Example program
#include <iostream>
#include <string>
#include <array>
#include <cmath>
using namespace std;
/*
int factorial(int n){
//base case
int result;
if (n==1){
return 1;
}
else{ //3*2*1
result=n*factorial(n-1);
}
return result;
}
bool sleepIn(bool weekday, bool vacation){
if (weekday==false || vacation==true){
return true;
}
}
bool monkey(bool a, bool b){
if ((a==true && b==true) || (a==false && b==false)){
return true;
}
}
int sum(int a, int b) {
if (a==b){
return 2*(a+b);
}
else{
return a+b;
}
}
int diff(int n){
if (n<21){
return 21-n;
}
else{
return 2*(n-21);
}
}
bool parrot(bool talk, int hour){
if ((talk==true) && (hour<7 || hour>20)){
return true;
}
}
bool makes(int a, int b){
if (a==10 || b==10){
return true;
}
else if (a+b==10){
return true;
}
else{
return false;
}
}
bool posNeg(int a, int b, bool negative){
if (negative==true){
if (a<0 && b<0){
return true;
}
}
else if ((a>0 && b<0) || (a<0 && b>0)){ // || b==true){
return true;
}
}
*/
int main(){
//cout<<factorial(3)<<endl<<factorial(1)<<endl<<factorial(5);
//cout<<sleepIn(false, false)<<endl<<sleepIn(true, false)<<endl<<sleepIn(false, true);
//cout<<monkey(true, true)<<endl<<monkey(false, false)<<endl<<monkey(true, false);
//cout<<sum(1, 2)<<endl<<sum(2, 2);
//cout<<diff(19)<<endl<<diff(22);
//cout<<parrot(true, 6)<<endl<<parrot(true, 7);
//cout<<makes(9, 10)<<endl<<makes(9, 9);
//cout<<posNeg(1, -1, false)<<endl<<posNeg(-4, -5, true);
}