回答編集履歴
1
ソース追記
test
CHANGED
@@ -11,3 +11,95 @@
|
|
11
11
|
error: use of undeclared identifier 'sort2'
|
12
12
|
|
13
13
|
```
|
14
|
+
|
15
|
+
「追記」
|
16
|
+
|
17
|
+
```text
|
18
|
+
|
19
|
+
usr ~/Project/test % ./a.out
|
20
|
+
|
21
|
+
2つの整数を入力してください
|
22
|
+
|
23
|
+
123 456
|
24
|
+
|
25
|
+
123
|
26
|
+
|
27
|
+
456
|
28
|
+
|
29
|
+
usr ~/Project/test % ./a.out
|
30
|
+
|
31
|
+
2つの整数を入力してください
|
32
|
+
|
33
|
+
456 123
|
34
|
+
|
35
|
+
123
|
36
|
+
|
37
|
+
456
|
38
|
+
|
39
|
+
usr ~/Project/test % cat t1.cpp
|
40
|
+
|
41
|
+
#include <iostream>
|
42
|
+
|
43
|
+
using namespace std;
|
44
|
+
|
45
|
+
|
46
|
+
|
47
|
+
void sort2(int *pValue1, int *pValue2);
|
48
|
+
|
49
|
+
|
50
|
+
|
51
|
+
/********************************
|
52
|
+
|
53
|
+
メイン関数
|
54
|
+
|
55
|
+
********************************/
|
56
|
+
|
57
|
+
int main()
|
58
|
+
|
59
|
+
{
|
60
|
+
|
61
|
+
|
62
|
+
|
63
|
+
int value1, value2;
|
64
|
+
|
65
|
+
|
66
|
+
|
67
|
+
cout << "2つの整数を入力してください" << endl;
|
68
|
+
|
69
|
+
|
70
|
+
|
71
|
+
cin >> value1 >> value2;
|
72
|
+
|
73
|
+
|
74
|
+
|
75
|
+
sort2(&value1, &value2);
|
76
|
+
|
77
|
+
|
78
|
+
|
79
|
+
cout << value1 << endl
|
80
|
+
|
81
|
+
<< value2 << endl;
|
82
|
+
|
83
|
+
}
|
84
|
+
|
85
|
+
|
86
|
+
|
87
|
+
void sort2(int *pValue1, int *pValue2)
|
88
|
+
|
89
|
+
{
|
90
|
+
|
91
|
+
if (*pValue1 > *pValue2) {
|
92
|
+
|
93
|
+
int temp = *pValue1;
|
94
|
+
|
95
|
+
*pValue1 = *pValue2;
|
96
|
+
|
97
|
+
*pValue2 = temp;
|
98
|
+
|
99
|
+
}
|
100
|
+
|
101
|
+
}
|
102
|
+
|
103
|
+
|
104
|
+
|
105
|
+
```
|