• 코드:
​x
 
1
#include <iostream>
2
using namespace std;
3
​
4
void Shift(int, int);
5
void Shift(int, int, int);
6
void Shift(int, int, int, int);
7
​
8
int main(void)
9
{
10
    Shift(1, 2);
11
    Shift(1, 2, 3);
12
    Shift(1, 2, 3, 4);
13
    return 0;
14
}
15
​
16
void Shift(int a, int b)
17
{
18
    int temp;
19
    
20
    temp = a;
21
    a = b;
22
    b = temp;
23
    
24
    cout << a << ", " << b << endl;
25
}
26
​
27
void Shift(int a, int b, int c)
28
{
29
    int temp;
30
    
31
    temp = a;
32
    a = b;
33
    b = c;
34
    c = temp;
35
    
36
    cout << a << ", " << b << ", " << c << endl;
37
}
38
​
39
void Shift(int a, int b, int c, int d)
40
{
41
    int temp;
42
    
43
    temp = a;
44
    a = b;
45
    b = c;
46
    c = d;
47
    d = temp;
48
    
49
    cout << a << ", " << b << ", " << c << ", " << d << endl;
50
}
표준입력 & 실행옵션