質問編集履歴
5
書式の更新
test
CHANGED
File without changes
|
test
CHANGED
@@ -12,7 +12,7 @@
|
|
12
12
|
|
13
13
|
eclipseを使用して,選択ソートのを作成したいです。
|
14
14
|
|
15
|
-
またoutput
|
15
|
+
またoutputを書きたい
|
16
16
|
|
17
17
|
```
|
18
18
|
|
@@ -110,11 +110,19 @@
|
|
110
110
|
|
111
111
|
for (int j = i + 1; j < array.length; j++)
|
112
112
|
|
113
|
-
if
|
113
|
+
if(array[j] < array[min]) min = j;
|
114
114
|
|
115
|
-
|
115
|
+
}
|
116
116
|
|
117
|
+
if(i != min) {
|
118
|
+
|
119
|
+
int tmp = array[min];
|
120
|
+
|
117
|
-
|
121
|
+
array[min] = array[i];
|
122
|
+
|
123
|
+
array[i] = tmp;
|
124
|
+
|
125
|
+
|
118
126
|
|
119
127
|
}
|
120
128
|
|
4
質問の更新
test
CHANGED
@@ -1 +1 @@
|
|
1
|
-
選択ソート
|
1
|
+
選択ソートを作成したいです。
|
test
CHANGED
@@ -10,9 +10,9 @@
|
|
10
10
|
|
11
11
|
```
|
12
12
|
|
13
|
-
|
13
|
+
eclipseを使用して,選択ソートのを作成したいです。
|
14
14
|
|
15
|
-
|
15
|
+
またoutputの書きが分からないです。
|
16
16
|
|
17
17
|
```
|
18
18
|
|
@@ -62,6 +62,36 @@
|
|
62
62
|
|
63
63
|
// ファイルを開いて全て読み込んで配列arrayに入れる
|
64
64
|
|
65
|
+
try {
|
66
|
+
|
67
|
+
BufferedReader br = new BufferedReader(new FileReader(filename));
|
68
|
+
|
69
|
+
String line;
|
70
|
+
|
71
|
+
while((line = br.readLine()) != null){
|
72
|
+
|
73
|
+
line = br.readLine();
|
74
|
+
|
75
|
+
}
|
76
|
+
|
77
|
+
} catch (FileNotFoundException e) {
|
78
|
+
|
79
|
+
// TODO 自動生成された catch ブロック
|
80
|
+
|
81
|
+
e.printStackTrace();
|
82
|
+
|
83
|
+
} catch (IOException e) {
|
84
|
+
|
85
|
+
// TODO 自動生成された catch ブロック
|
86
|
+
|
87
|
+
e.printStackTrace();
|
88
|
+
|
89
|
+
}
|
90
|
+
|
91
|
+
System.out.println(array);
|
92
|
+
|
93
|
+
|
94
|
+
|
65
95
|
}
|
66
96
|
|
67
97
|
public void sort() {
|
@@ -71,6 +101,22 @@
|
|
71
101
|
// ソートを実装する
|
72
102
|
|
73
103
|
// 配列arrayの中身をソートする
|
104
|
+
|
105
|
+
for (int i = 0; i < array.length; i++)
|
106
|
+
|
107
|
+
{
|
108
|
+
|
109
|
+
int min = i;
|
110
|
+
|
111
|
+
for (int j = i + 1; j < array.length; j++)
|
112
|
+
|
113
|
+
if ( array[min].CompareTo( array[j]) > 0)
|
114
|
+
|
115
|
+
min = j;
|
116
|
+
|
117
|
+
Swap(ref array[i], ref array[min]);
|
118
|
+
|
119
|
+
}
|
74
120
|
|
75
121
|
}
|
76
122
|
|
@@ -108,29 +154,7 @@
|
|
108
154
|
|
109
155
|
```
|
110
156
|
|
111
|
-
### 試したこと
|
112
157
|
|
113
|
-
```ここに言語名を入力
|
114
|
-
|
115
|
-
public void sort() {
|
116
|
-
|
117
|
-
for (int i = 0; i < array.length; i++)
|
118
|
-
|
119
|
-
{
|
120
|
-
|
121
|
-
int min = i;
|
122
|
-
|
123
|
-
for (int j = i + 1; j < array.length; j++)
|
124
|
-
|
125
|
-
if ( array[min].CompareTo( array[j]) > 0)
|
126
|
-
|
127
|
-
min = j;
|
128
|
-
|
129
|
-
Swap(ref array[i], ref array[min]);
|
130
|
-
|
131
|
-
}
|
132
|
-
|
133
|
-
```
|
134
158
|
|
135
159
|
### 補足情報(FW/ツールのバージョンなど)
|
136
160
|
|
3
質問の更新
test
CHANGED
@@ -1 +1 @@
|
|
1
|
-
選択
|
1
|
+
選択ソートクラスを作成が分からない
|
test
CHANGED
@@ -11,6 +11,8 @@
|
|
11
11
|
```
|
12
12
|
|
13
13
|
挿入ソートクラスの作成がわからない、 public void sort() 中身の書き方を質問したいです
|
14
|
+
|
15
|
+
|
14
16
|
|
15
17
|
```
|
16
18
|
|
@@ -108,16 +110,30 @@
|
|
108
110
|
|
109
111
|
### 試したこと
|
110
112
|
|
113
|
+
```ここに言語名を入力
|
111
114
|
|
115
|
+
public void sort() {
|
112
116
|
|
113
|
-
|
117
|
+
for (int i = 0; i < array.length; i++)
|
114
118
|
|
119
|
+
{
|
115
120
|
|
121
|
+
int min = i;
|
122
|
+
|
123
|
+
for (int j = i + 1; j < array.length; j++)
|
124
|
+
|
125
|
+
if ( array[min].CompareTo( array[j]) > 0)
|
126
|
+
|
127
|
+
min = j;
|
128
|
+
|
129
|
+
Swap(ref array[i], ref array[min]);
|
130
|
+
|
131
|
+
}
|
132
|
+
|
133
|
+
```
|
116
134
|
|
117
135
|
### 補足情報(FW/ツールのバージョンなど)
|
118
136
|
|
119
137
|
eclipseを使用しています。
|
120
138
|
|
121
139
|
よろしくお願いします
|
122
|
-
|
123
|
-
ここにより詳細な情報を記載してください。
|
2
質問の更新
test
CHANGED
File without changes
|
test
CHANGED
@@ -10,7 +10,7 @@
|
|
10
10
|
|
11
11
|
```
|
12
12
|
|
13
|
-
|
13
|
+
挿入ソートクラスの作成がわからない、 public void sort() 中身の書き方を質問したいです
|
14
14
|
|
15
15
|
```
|
16
16
|
|
1
```を貼り付けだ
test
CHANGED
File without changes
|
test
CHANGED
@@ -104,7 +104,7 @@
|
|
104
104
|
|
105
105
|
}
|
106
106
|
|
107
|
-
|
107
|
+
```
|
108
108
|
|
109
109
|
### 試したこと
|
110
110
|
|