Guest User

Untitled

a guest
Jun 19th, 2018
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.26 KB | None | 0 0
  1. import java.util.*;
  2. class P27Ex39
  3. {
  4. static Scanner reader= new Scanner(System.in);
  5. public static void main(String[] args)
  6. {
  7. int first=0 , sec=0 , th=0 , v1 , v2 , v3;
  8. int[] comp=new int[51];
  9.  
  10. for (int i=1 ; i<=10 ; i++)
  11. {
  12. System.out.println(" הכנס מקום ראשון , שני , ושלישי ");
  13. v1=reader.nextInt();
  14. v2=reader.nextInt();
  15. v3=reader.nextInt();
  16.  
  17. comp[v1]+=3;
  18. comp[v2]+=2;
  19. comp[v3]+=1;
  20. }
  21.  
  22. if ( comp [1] > comp[2])
  23. {
  24. first=comp[1];
  25. sec=comp[2];
  26. }
  27. else
  28. {
  29. first=comp[2];
  30. sec=comp[1];
  31. }
  32. for ( int i=3 ; i<comp.length ; i++)
  33. {
  34. if ( comp[i]>first)
  35. {
  36. th=sec;
  37. sec=first;
  38. first=comp[i];
  39. }
  40. else if (comp[i]>sec)
  41. {
  42. th=sec;
  43. sec=comp[i];
  44. }
  45. else if (comp[i]>th)
  46. th=comp[i];
  47.  
  48. }
  49.  
  50. System.out.println("מקום ראשון : " + first + " מקום שני : " + sec + "מקום שלישי" + th);
  51.  
  52. }
  53. }
Add Comment
Please, Sign In to add comment