Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*сверху вниз*/
- public static void sort(int[] array)
- {
- //Напишите тут ваш код
- int j;
- boolean flag = true;
- int temp;
- while (flag) {
- flag = false;
- for (j = 0; j < array.length - 1; j++) {
- if (array[j] < array[j+1]) {
- temp = array[j];
- array[j] = array [j + 1];
- array[j + 1] = temp;
- flag = true;
- }
- }
- }
- }
- /*===================================================*/
- /*cнизу вверх*/
- public static void sort(int[] array)
- {
- //Напишите тут ваш код
- int j;
- boolean flag = true;
- int temp;
- while (flag) {
- flag = false;
- for (j = 0; j < array.length - 1; j++) {
- if (array[j] > array[j+1]) {
- temp = array[j];
- array[j] = array [j + 1];
- array[j + 1] = temp;
- flag = true;
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment