Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * To change this template, choose Tools | Templates
- * and open the template in the editor.
- */
- package javaapplication2;
- import java.util.Random;
- /**
- *
- * @author caio.43169
- */
- public class JavaApplication2 {
- /**
- * @param args the command line arguments
- */
- public static void main(String[] args) {
- int a[] = new int[20];//inicializa vetores
- int b[] = null;//par
- int c[] = null;//impar
- Random rand = new Random(20);
- for(int i = 0; i<20;i++)//inicializa um varivel; condição; contador
- {
- a[i] = 1+rand.nextInt();
- System.out.print("\n"+ a[i]);
- if(a[i] % 2 ==0)
- {
- for(int j = 0;j<a.length;j++)
- {
- b[j] = a[i];
- }
- //par
- }
- else
- {
- for(int m = 0;m < a.length;m++)
- {
- c[m] = a[i];
- }
- //impar
- }
- for(int k = 0;k<20;k++)
- {
- System.out.println(" \t vetor a " + a[k] + "\t par " + b[k] + "\t impar " + c[k]);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement