Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package zh_1;
- import java.util.Random;
- public class zhTIZa {
- public static void main(String[] args) {
- // TODO Auto-generated method stub
- int [] tomb = new int[20];
- int tizig = tomb.length-10;
- int [] kettovel = new int[20];
- for (int i = 0; i < tizig; i++) { //elso tiz elem
- tomb[i] = 7;
- }
- for (int i = 10; i < tomb.length; i++){ //masodik tiz elem
- int rnd = (int) ((Math.random()*30)+5);
- tomb[i] = rnd;
- }
- for (int i = 0; i<tomb.length; i++) { //tomb listazasa
- System.out.println(tomb[i]);
- }
- System.out.println("");
- System.out.println("Párosak:");
- for (int i = 0; i < tomb.length; i++) {
- if (tomb[i] % 2 == 0){
- System.out.println(tomb[i]);
- }
- }
- System.out.println("Öttel oszthatóak:");
- for (int i = 0; i < tomb.length; i++) {
- if (tomb[i] % 5 == 0){
- System.out.println(tomb[i]);
- }
- ;
- }
- System.out.println("");
- double d = 2.5;
- double harmas = tomb[3]/d;
- double tizennegy = tomb[14]/d;
- double tizenot = tomb[15]/d;
- System.out.println("3.elem= " + tomb[3] + ", " + tomb[3] + "/" + d + "=" + harmas);
- System.out.println("14.elem= " + tomb[14] + ", " + tomb[14] + "/" + d + "=" + tizennegy);
- System.out.println("15.elem= " + tomb[15] + ", " + tomb[15] + "/" + d + "=" + tizenot);
- } //main zaro
- } //class zaro
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement