Advertisement
Guest User

Untitled

a guest
Nov 24th, 2014
123
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.40 KB | None | 0 0
  1. package zh_1;
  2.  
  3. import java.util.Random;
  4.  
  5. public class zhTIZa {
  6.  
  7. public static void main(String[] args) {
  8. // TODO Auto-generated method stub
  9.  
  10. int [] tomb = new int[20];
  11. int tizig = tomb.length-10;
  12. int [] kettovel = new int[20];
  13.  
  14.  
  15. for (int i = 0; i < tizig; i++) { //elso tiz elem
  16. tomb[i] = 7;
  17. }
  18.  
  19. for (int i = 10; i < tomb.length; i++){ //masodik tiz elem
  20. int rnd = (int) ((Math.random()*30)+5);
  21. tomb[i] = rnd;
  22.  
  23.  
  24. }
  25. for (int i = 0; i<tomb.length; i++) { //tomb listazasa
  26. System.out.println(tomb[i]);
  27.  
  28. }
  29.  
  30.  
  31. System.out.println("");
  32. System.out.println("Párosak:");
  33.  
  34. for (int i = 0; i < tomb.length; i++) {
  35. if (tomb[i] % 2 == 0){
  36. System.out.println(tomb[i]);
  37. }
  38.  
  39. }
  40.  
  41. System.out.println("Öttel oszthatóak:");
  42.  
  43. for (int i = 0; i < tomb.length; i++) {
  44. if (tomb[i] % 5 == 0){
  45. System.out.println(tomb[i]);
  46.  
  47. }
  48. ;
  49. }
  50.  
  51. System.out.println("");
  52.  
  53. double d = 2.5;
  54. double harmas = tomb[3]/d;
  55. double tizennegy = tomb[14]/d;
  56. double tizenot = tomb[15]/d;
  57. System.out.println("3.elem= " + tomb[3] + ", " + tomb[3] + "/" + d + "=" + harmas);
  58. System.out.println("14.elem= " + tomb[14] + ", " + tomb[14] + "/" + d + "=" + tizennegy);
  59. System.out.println("15.elem= " + tomb[15] + ", " + tomb[15] + "/" + d + "=" + tizenot);
  60.  
  61.  
  62.  
  63. } //main zaro
  64.  
  65.  
  66. } //class zaro
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement