-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDrillCH8.2.cpp
79 lines (64 loc) · 1.59 KB
/
DrillCH8.2.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
#include "std_lib_facilities.h"
//-------------------------------------------------------------
void swap_v(int a, int b)
{
int temp;
temp = a, a = b;
b = temp;
cout << "swap_v x: " << a << " y: " << b << endl;
}
//-------------------------------------------------------------
void swap_r(int& a, int& b) //referenciák, value nem adható át
{
int temp;
temp = a, a = b;
b = temp;
cout << "swap_r x: " << a << " y: " << b << endl;
}
//-------------------------------------------------------------
void swap_cr(const int& a, const int& b) //konstansokat nem lehet változtatni
{
int temp;
temp = a;
//a = b;
//b = temp;
cout << "swap_cr x: " << a << " y: " << b << endl;
}
int main() {
/*int x = 7;
int y = 9;
swap_v(x, y);
swap_v(7, 9);
const int cx = 7;
const int cy = 9;
swap_v(cx, cy);
swap_v(7.7, 9.9);
double dx = 7.7;
double dy = 9.9;
swap_v(dx, dy);
swap_v(7.7, 9.9);*/
/* int x = 7;
int y = 9;
swap_r(x, y);
//swap_r(7, 9); //Ez a verzió nem tud intbõl int&be konvertálni
const int cx = 7;
const int cy = 9;
//swap_r(cx, cy); //Ez a verzió sem mûködik
//swap_r(7.7, 9.9);
double dx = 7.7;
double dy = 9.9;
//swap_r(dx, dy);
//swap_r(7.7, 9.9);*/
int x = 7;
int y = 9;
swap_cr(x, y);
swap_cr(7, 9);
const int cx = 7;
const int cy = 9;
swap_cr(cx, cy);
swap_cr(7.7, 9.9);
double dx = 7.7;
double dy = 9.9;
swap_cr(dx, dy);
swap_cr(7.7, 9.9);
}