-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathlab5_1.cpp
116 lines (94 loc) · 2.15 KB
/
lab5_1.cpp
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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
#include <iostream>
#include <string>
#include <vector>
#include "my_swap.hpp"
void printVector(const std::vector<std::string> & vec)
{
for (std::size_t i = 0; i < vec.size(); ++i)
{
std::cout << vec[i] << " ";
}
std::cout << std::endl;
}
void exp1(int a)
{
a += 10;
}
void exp2(int& a)
{
a += 10;
}
int max(int a, int b)
{
return (a > b) ? a : b;
}
int main()
{
{
int max = 0;
int x = 0;
int y = 0;
std::cout << "enter x and y" << std::endl;
std::cin >> x >> y;
if (x > y)
max = x;
else
max = y;
std::cout << "maximum is " << max << std::endl;
int n = 100;
int m = 0;
std::cout << "enter m" << std::endl;
std::cin >> m;
if (n > m)
max = n;
else
max = m;
std::cout << "maximum is " << max << std::endl;
int k = 20;
int l = 1234;
std::cout << "k=20 and l=1234" << std::endl;
if (k > l)
max = k;
else
max = l;
std::cout << "maximum is " << max << std::endl;
}
{
int x = 0;
int y = 0;
std::cout << "enter x and y" << std::endl;
std::cin >> x >> y;
std::cout << "maximum is " << max(x, y) << std::endl;
int n = 100;
int m = 0;
std::cout << "enter m" << std::endl;
std::cin >> n >> m;
std::cout << "maximum is " << max(n, m) << std::endl;
int l = 1234;
int d = max(10, l);
std::cout << "maximum is " << d << std::endl;
}
{
int x = 10;
int y = 100;
// implement swap
std::cout << "x = " << x << std::endl;
std::cout << "y = " << y << std::endl;
}
{
int x = 13;
std::cout << "x = " << x << std::endl;
exp1(x);
std::cout << "x = " << x << std::endl;
exp2(x);
std::cout << "x = " << x << std::endl;
}
{
int x = 10;
int y = 100;
swap(x, y);
std::cout << "x = " << x << std::endl;
std::cout << "y = " << y << std::endl;
}
return 0;
}