import java.util.Scanner;
public class Ascending {
public static void main(String[] args) {
int temp;
Scanner in = new Scanner(System.in);
int a[] = new int[10];
for (int i = 0; i <= 9; i++) {
System.out.println("Enter element no. " + (i + 1));
a[i] = in.nextInt();
}
for (int i = 0; i <= 9; i++) {
for (int j = i + 1; j <= 9; j++) {
if (a[i] > a[j]) {
temp = a[i];
a[i] = a[j];
a[j] = temp;
}
}
}
for (int i = 0; i <= 9; i++) {
System.out.print(a[i] + " ");
}
}
}
public class Ascending {
public static void main(String[] args) {
int temp;
Scanner in = new Scanner(System.in);
int a[] = new int[10];
for (int i = 0; i <= 9; i++) {
System.out.println("Enter element no. " + (i + 1));
a[i] = in.nextInt();
}
for (int i = 0; i <= 9; i++) {
for (int j = i + 1; j <= 9; j++) {
if (a[i] > a[j]) {
temp = a[i];
a[i] = a[j];
a[j] = temp;
}
}
}
for (int i = 0; i <= 9; i++) {
System.out.print(a[i] + " ");
}
}
}
No comments:
Post a Comment