Advertisement
urksiful

PRACTICA PREFINAL CODE JAGUAR

Nov 26th, 2015
158
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.02 KB | None | 0 0
  1.  
  2. import java.util.Scanner;
  3.  
  4. public class Main {
  5.  
  6.     public static void main(String[] args) {
  7.         Scanner xr = new Scanner(System.in);
  8.        
  9.         int num = xr.nextInt();
  10.         int tamaño = ((num*(num-1))/2)+num;
  11.        
  12.         int arreglo[] = new int [tamaño];
  13.         //Creamos la sucesion
  14.         int cont = 0;
  15.         int pares = 0;
  16.         int impares = 0;
  17.        
  18.         for (int i = 1; i<=num; i++) {
  19.             for (int j = i; j > 0; j--) {
  20.                     arreglo[cont] = (i*i);
  21.                    
  22.                     if(arreglo[cont] % 2 == 0){
  23.                         pares++;
  24.                     }else{
  25.                         impares++;
  26.                     }
  27.                     System.out.print("1/"+(i*i)+" + ");
  28.                     cont++;
  29.             }
  30.         }
  31.        
  32.         System.out.println("\nPares: "+pares);
  33.         System.out.println("Impares: "+impares);
  34.         for(int temporal:arreglo){
  35.             System.out.print(temporal+" ");
  36.         }
  37.     }
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement