We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent d7148f6 commit 7888639Copy full SHA for 7888639
Daily_Coding_Problem-05.cpp
@@ -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