Open gabelkova123 opened 1 year ago
package lab5;
import java.util.Random; public class zad1 { public static void main(String[] args) {
int[] numbers = new int[25];
int max = Integer.MIN_VALUE;
int min = Integer.MAX_VALUE;
int imax = 0, imin = 0, swap;
Random random = new Random();
//Ввод массива и присваивания мин и макс числу знач 0
System.out.println("Исходный массив:" );
for (int k = 0; k < numbers.length; k++) {
numbers[k] = random.nextInt(100);
System.out.print(numbers[k]);
for (int i = k+1; i < numbers.length ; i++) {
if (numbers[i] < min)
min = numbers[i];
imin = i;
}
if (j != imin) {
int temp = numbers[j];
numbers[j] = numbers[imin];
numbers[imin] = temp;
}
System.out.println ();
for (int i : numbers){
System.out.println(i + " ");
}
}
}
}
for (int i = 0; i < numbers.length - 1; i++) { for (int j = 0; j < numbers.length - i - 1; j++) { if (numbers[j] > numbers[j + 1]) { int temp = numbers[j]; numbers[j] = numbers[j + 1]; numbers[j + 1] = temp; }