Untitled
unknown
plain_text
3 years ago
1.2 kB
8
Indexable
import java.util.*;
public class Main {
public static void minToBegin(int a[]){
int min_num = a[0], min_index = 0, temp;
for(int i = 1; i < a.length; i++){
if(a[i] < min_num){
min_index = i;
min_num = a[i];
}
}
while (min_index > 0){
a[min_index] = a[min_index-1];
min_index--;
}
a[0] = min_num;
for(int i = 0; i < a.length; i++){
System.out.print(a[i] + " ");
}
}
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int N = in.nextInt(), a[] = new int[N];
for(int i = 0; i < a.length; i++){
a[i] = in.nextInt();
}
minToBegin(a);
}
}
/* ответ де-факто
* public static void minToBegin(int a[]){
int min_num = a[0], min_index = 0, temp;
for(int i = 1; i < a.length; i++){
if(a[i] < min_num){
min_index = i;
min_num = a[i];
}
}
while (min_index > 0){
a[min_index] = a[min_index-1];
min_index--;
}
a[0] = min_num;*/Editor is loading...