invina_

Untitled

Oct 16th, 2018
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.60 KB | None | 0 0
  1. package create_array_100;
  2.  
  3. import java.util.Random;
  4.  
  5. public class array {
  6.  
  7. final static Random random = new Random();
  8.  
  9. public static void main(String[] args){
  10. int a[] = new int [100];
  11. String str ="";
  12.  
  13. for (int i=0; i<100; i++)
  14. {
  15. a[i] = random.nextInt(50);
  16. str+= a[i] + " ";
  17.  
  18. }
  19. System.out.println ("наш массив: " + str);
  20.  
  21.  
  22. String strch = a[0] + " ";
  23. int res = a[0];
  24. for(int i=2; i<100; i++)
  25. {
  26. strch+=a[i]+ " ";
  27. res= res*a[i];
  28. i++;
  29. }
  30. System.out.println ("четные: " + strch);
  31. System.out.println ("произведение четных: " + res);
  32. }
  33. }
Advertisement
Add Comment
Please, Sign In to add comment