teratail header banner
teratail header banner
質問するログイン新規登録

回答編集履歴

1

ソース追記

2019/10/24 10:28

投稿

cateye
cateye

スコア6851

answer CHANGED
@@ -4,4 +4,50 @@
4
4
 
5
5
  ```text
6
6
  error: use of undeclared identifier 'sort2'
7
+ ```
8
+ 「追記」
9
+ ```text
10
+ usr ~/Project/test % ./a.out
11
+ 2つの整数を入力してください
12
+ 123 456
13
+ 123
14
+ 456
15
+ usr ~/Project/test % ./a.out
16
+ 2つの整数を入力してください
17
+ 456 123
18
+ 123
19
+ 456
20
+ usr ~/Project/test % cat t1.cpp
21
+ #include <iostream>
22
+ using namespace std;
23
+
24
+ void sort2(int *pValue1, int *pValue2);
25
+
26
+ /********************************
27
+ メイン関数
28
+ ********************************/
29
+ int main()
30
+ {
31
+
32
+ int value1, value2;
33
+
34
+ cout << "2つの整数を入力してください" << endl;
35
+
36
+ cin >> value1 >> value2;
37
+
38
+ sort2(&value1, &value2);
39
+
40
+ cout << value1 << endl
41
+ << value2 << endl;
42
+ }
43
+
44
+ void sort2(int *pValue1, int *pValue2)
45
+ {
46
+ if (*pValue1 > *pValue2) {
47
+ int temp = *pValue1;
48
+ *pValue1 = *pValue2;
49
+ *pValue2 = temp;
50
+ }
51
+ }
52
+
7
53
  ```