Translation is not possible.

// Massivni oddiy saralash classi:

class SelectionSortArray

{

public static void main(String[] Sardor)

{

// kiritish uchun:

Scanner in = new Scanner(System.in);

// har xil sonlarni generatsiya qilish uchun:

Random rnd = new Random();

// massiv elemenlari soni:

int arrSize;

System.out.print("Massiv uzunligi: ");

arrSize = in.nextInt();

// shu uzunlikdagi int tipidagi massiv:

int array[] = new int[arrSize];

// aralash har xil qiymatlar beramiz:

for (int i = 0; // massiv boshidan,

i < array.length; // massiv oxirigacha

i++) // 1 odimdan

{ // har bir elementga random qiymat beramiz:

array[i] = rnd.nextInt(arrSize + 1);

}

// chiqaramiz:

for (int i : array)

{

System.out.print(i + " ");

}

System.out.println("

O'sish tartibida saralangan massiv: ");

for (int i = 0; i < array.length - 1; i++)

{

int minElemIndex = i;

for (int j = i + 1; j < array.length; j++)

{

if (array[i] > array[j])

{

array[i] = array[i] ^ array[j];

array[j] = array[i] ^ array[j];

array[i] = array[i] ^ array[j];

}

}

}

for (int i : array)

{

System.out.print(i + " ");

}

System.out.println("

");

main(Sardor);

in.close();

}

}

Send as a message
Share on my page
Share in the group