バブルソートの使用と昇順または降順のソートについて助けが必要です:(
int[] number = {12, 5, 6, 14, 18};
int[] number = new int[5];
String[] mark = new String[10];
String evenOrOdd = "";
String output = "";
JTextArea textArea = new JTextArea(12,30);
for(int i = 0; i < number.length; i++) {
number[i] = Integer.parseInt(JOptionPane.showInputDialog("Enter a number"));
if (number[i] % 2 == 0) {
evenOrOdd = "even";
}
else {
evenOrOdd = "odd ";
}
mark[i] = "";
for(int j = 0; j < number[i]; j++) {
mark[i] = mark[i] + "*";
}
output = output + number[i] + "\t";
output = output + evenOrOdd + "\t";
output = output + mark[i] + "\n";
}
textArea.setText("numbers\ttype\tgraph\n" + output);
JOptionPane.showMessageDialog(null,
textArea,
"OUTPUT",
JOptionPane.INFORMATION_MESSAGE);
System.exit(0);
}
}
}
コードにはバブルの並べ替えがなく、どこに置くべきかわかりません。誰か助けてくれませんか?ユーザーが何も入力する必要はありません。