Skip to content

Commit 7888639

Browse files
committed
feat: solved problem 05
1 parent d7148f6 commit 7888639

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

Daily_Coding_Problem-05.cpp

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
/* MARK: - SOLUTION ✨ */
2+
3+
#include "Daily_Coding_Problem.h"
4+
5+
// MARK: - Solution
6+
7+
// This is the implementation of cons function
8+
pair<int, int>cons(int a, int b) {
9+
return make_pair(a, b);
10+
}
11+
12+
// This is the implementation of car function that returns the first element of the pair (a)
13+
int car(pair<int, int> p) {
14+
return p.first;
15+
}
16+
17+
// This is the implementation of cdr function that returns the last element of the pair (b)
18+
int cdr(pair<int, int> p) {
19+
return p.second;
20+
}
21+
22+
// MARK: - Main func
23+
int main()
24+
{
25+
pair<int, int> p = cons(3,4);
26+
cout << car(p) << endl;
27+
cout << cdr(p) << endl;
28+
}

0 commit comments

Comments
 (0)