import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
//ArrayListのlistを宣言
ArrayList<Integer> list = new ArrayList<Integer>();
//countは繰り返し回数
int count = 0;
count = scanner.nextInt();
//listに入力値を格納
for (int i = 0; i < count; i++) {
list.add(scanner.nextInt());
}
//ArrayListのバブルソート
for (int i = 0; i < list.size() - 1; i++) {
for (int j = list.size() - 1; j > i; j--) {
if (array.get(j - 1) > list.get(j)) {
// 入れ替え
int tmp = list.get(j - 1);
list.set(j -1, list.get(j));
list.set(j, tmp);
}
}
}
//拡張for文
for(int a: list) {
System.out.println(a);
}
}
}
More than 3 years have passed since last update.
Register as a new user and use Qiita more conveniently
- You get articles that match your needs
- You can efficiently read back useful information
- You can use dark theme
List of users who liked
00