-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlab13_4.cpp
More file actions
42 lines (33 loc) · 780 Bytes
/
lab13_4.cpp
File metadata and controls
42 lines (33 loc) · 780 Bytes
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
#include<iostream>
using namespace std;
template <class T>
void mySwap(T &,T &);
int main(){
int x, y;
string a, b;
char p, q;
cin >> x >> y >> a >> b >> p >> q;
cout << "Before swapping:\n";
cout << "x = " << x << ", y = " << y << "\n";
mySwap(x,y);
cout << "After swapping:\n";
cout << "x = " << x << ", y = " << y << "\n";
cout << "Before swapping:\n";
cout << "a = " << a << ", b = " << b << "\n";
mySwap(a,b);
cout << "After swapping:\n";
cout << "a = " << a << ", b = " << b << "\n";
cout << "Before swapping:\n";
cout << "p = " << p << ", q = " << q << "\n";
mySwap(p,q);
cout << "After swapping:\n";
cout << "p = " << p << ", q = " << q << "\n";
return 0;
}
template <class T>
void mySwap(T &x,T &y){
T num;
num = x;
x = y;
y = num;
}