Advertisement
caiofersousa

Untitled

Nov 25th, 2014
158
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.37 KB | None | 0 0
  1. /*
  2.  * To change this template, choose Tools | Templates
  3.  * and open the template in the editor.
  4.  */
  5. package javaapplication2;
  6.  
  7. import java.util.Random;
  8.  
  9. /**
  10.  *
  11.  * @author caio.43169
  12.  */
  13. public class JavaApplication2 {
  14.  
  15.     /**
  16.      * @param args the command line arguments
  17.      */
  18.     public static void main(String[] args) {
  19.        
  20.        
  21.         int a[] = new int[20];//inicializa vetores
  22.         int b[] = null;//par
  23.         int c[] = null;//impar
  24.        
  25.         Random rand = new Random(20);
  26.        
  27.        
  28.         for(int i = 0; i<20;i++)//inicializa um varivel; condição; contador
  29.         {
  30.              a[i]  = 1+rand.nextInt();            
  31.             System.out.print("\n"+  a[i]);
  32.             if(a[i] % 2 ==0)
  33.             {
  34.                for(int j = 0;j<a.length;j++)
  35.                {
  36.                     b[j] = a[i];
  37.                }
  38.                 //par
  39.             }
  40.             else
  41.             {
  42.               for(int m = 0;m < a.length;m++)
  43.               {
  44.                 c[m] = a[i];            
  45.               }
  46.               //impar
  47.             }
  48.                
  49.                 for(int k = 0;k<20;k++)
  50.                 {
  51.                     System.out.println("  \t vetor a  " + a[k] + "\t par " + b[k] + "\t impar  " + c[k]);
  52.                 }
  53.        
  54.         }
  55.        
  56.        
  57.        
  58.        
  59.     }
  60. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement