Advertisement
Guest User

Untitled

a guest
Feb 20th, 2017
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.09 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class Solution {
  4.    
  5.     public static void main(String[] args) {
  6.        
  7.         Scanner scan = new Scanner(System.in);
  8.         int count = scan.nextInt();
  9.         int[] arr = new int[count];
  10.         int[] arrRe = new int[count];
  11.         for (int x = 0; x < count; x++) {
  12.             arr[x] = scan.nextInt();
  13.             arrRe[x] = arr[x];
  14.         }
  15.        
  16.         while (true) {
  17.             boolean flag = false;
  18.            
  19.             for (int x = 1; x < count; x++) {
  20.                 if (arrRe[x] > arrRe[x-1]) {
  21.                     int temp = arrRe[x-1];
  22.                     arrRe[x-1] = arrRe[x];
  23.                     arrRe[x] = temp;
  24.                     flag = true;
  25.                 }
  26.             }
  27.            
  28.             if (flag == false) {
  29.                 break;
  30.             }
  31.         }
  32.        
  33.         for (int x = 0; x < count; x++) {
  34.             for (int y = 0; y < count; y++) {
  35.                 if (arr[x] == arrRe[y]) {
  36.                     System.out.print((y+1) + " ");
  37.                 }
  38.             }
  39.         }
  40.     }
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement