1-topshiriq
7. to'rtta o'zgaruvchining qiymatlarini faqat shartli operatorlar yordamida saralash
import java.util.Scanner;
public class PrinterUchun {
public static void main(String args[]){
Scanner cin = new Scanner(System.in);
int a,b,c,d;
System.out.print("1-o'zgaruvchini kiriting: ");
a = cin.nextInt();
System.out.print("2-o'zgaruvchini kiriting: ");
b = cin.nextInt();
System.out.print("3-o'zgaruvchini kiriting: ");
c = cin.nextInt();
System.out.print("4-o'zgaruvchini kiriting: ");
d = cin.nextInt();
int m[] = new int[4];
m[0] = a;
m[1] = b;
m[2] = c;
m[3] = d;
for (int i=0; ifor (int j=i;jif (m[i] > m[j]) {
int time = m[i];
m[i] = m[j];
m[j] = time;
}
}
}
for (int i=0;iSystem.out.println(m[i]);
}
}
}
Do'stlaringiz bilan baham: |