Advertisement
Guest User

Untitled

a guest
Dec 8th, 2019
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.78 KB | None | 0 0
  1. import java.util.Scanner;
  2. public class Exam {
  3. public static void main(String[] args) {
  4. Scanner sc = new Scanner(System.in);
  5. int N = sc.nextInt(); //amount of players
  6. int R = sc.nextInt(); //amount of rounds
  7.  
  8. int[] sum = new int[N];
  9. int[] worstRank = new int[N];
  10. for (int i=0; i<R; i++) { //repeat round
  11. for (int j=0; j<N; j++) { //using j to repeat players
  12. sum[j]+=sc.nextInt();
  13. }
  14. //finished sum
  15. //find out the rank
  16. for (int j=0; j<N; j++) {//find out player j's rank
  17. //each player compare with every player
  18. int rank = 1;
  19. for (int k=0; k<N; k++) {
  20. if (sum[j]<sum[k]) { //j is you k is other
  21. rank++;
  22. }
  23. }
  24. if (worstRank[j]<rank) {
  25. worstRank[j] = rank;
  26. }
  27.  
  28. }
  29.  
  30. }
  31.  
  32.  
  33. }
  34.  
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement