Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package javaapplication3;
- import java.util.Scanner;
- public class JavaApplication3 {
- public static void main(String[] args) {
- Scanner input = new Scanner(System.in);
- int i = 0;
- int[] vec = new int[10];
- while(i < 10){
- System.out.println("n ");
- vec[i] = input.nextInt();
- i +=1;
- }
- int[] sample = vec;
- i = 0;
- int j = i + 1;
- int aux;
- while(i < sample.length){
- while(j < sample.length){
- if(sample[i] < sample[j]){
- aux = sample[j];
- while(j > i){
- j = j - 1;
- sample[j + 1] = sample[j];
- }
- sample[j] = aux;
- j = i + 1;
- }
- else{
- j += 1;
- }
- }
- i += 1;
- j = 1 + i;
- }
- i = 0;
- while(i < sample.length){
- System.out.println(sample[i]);
- i += 1;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement