Guest User

Untitled

a guest
Oct 15th, 2018
169
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.87 KB | None | 0 0
  1. import java.io.BufferedReader;
  2. import java.io.IOException;
  3. import java.io.InputStreamReader;
  4. import java.util.Vector;
  5.  
  6. public class Main {
  7. public static int total;
  8. public static void main(String[] args) throws IOException {
  9. BufferedReader leitor = new BufferedReader(new InputStreamReader(System.in));
  10.  
  11. int a = Integer.parseInt(leitor.readLine());
  12. int[] vet = new int[a];
  13. int b = 0;
  14. int c = 0;
  15. for(int q=0;q<a;q++){
  16. b = Integer.parseInt(leitor.readLine());
  17. vet[c] = b;
  18. c++;
  19. }
  20. Main.total =0;
  21. for(int i =0;i<vet.length;i++){
  22. for(int j = i+1;j<vet.length;j++){
  23. if(vet[i]>vet[j]){
  24. Main.total++;
  25. }
  26. }
  27. }
  28. System.out.println(Main.total);
  29. }
  30.  
  31. }
Advertisement
Add Comment
Please, Sign In to add comment