






















Prepara tus exámenes y mejora tus resultados gracias a la gran cantidad de recursos disponibles en Docsity
Gana puntos ayudando a otros estudiantes o consíguelos activando un Plan Premium
Esta página no es visible en la vista previa
¡No te pierdas las partes importantes!























import java.util.Scanner; public class Main { public static void main(String[]args){ int mayor, menor; Scanner sc=new Scanner(System.in); int ar[]=new int[ 10 ]; for(int x= 0 ; x< 10 ;x++){ ar[x]=sc.nextInt(); } mayor=menor=ar[ 0 ]; for(int x= 0 ; x< 10 ;x++){ if(ar[x]>mayor){ mayor=ar[x]; } if(ar[x]<menor){ menor=ar[x]; } } System.out.println(menor+" "+mayor +" "+(mayor-menor)); } }
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.Scanner; public class Main { public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader( new InputStreamReader(System.in)); // TODO: fixme. Scanner sc=new Scanner(System.in); int n=sc.nextInt(); int[] ar1=new int[n]; int[] ar2=new int[n]; for(int i=0; i<n; i++){ ar1[i]=sc.nextInt(); } for(int i=0; i<n; i++){ ar2[i]=sc.nextInt(); } int con=0; while(con<n){ if((ar1[con])<=(ar2[con])){ System.out.println("0"); break; } con++; } if(con==n){ System.out.println("1"); } } }
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.Scanner; public class Main { public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader( new InputStreamReader(System.in)); // TODO: fixme. Scanner sc = new Scanner(System.in); int n= sc.nextInt(); int[] arg = new int [n]; arg= new int[n]; for(int i= 0 ; i<n; i++){ arg[i]= sc.nextInt();} int k= sc.nextInt(); for(int i= 0 ; i<n; i++){ if(arg[i]%k== 0 ){ System.out.println(arg[i]);} else{ System.out.println("X");} } } }
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.Scanner; public class Main { public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader( new InputStreamReader(System.in)); // TODO: fixme. Scanner sc = new Scanner(System.in); int n= sc.nextInt(); int[] arg = new int [n]; arg= new int[n]; for(int i= 0 ; i<n; i++){ arg[i]= sc.nextInt();} int k= sc.nextInt(); for(int i= 0 ; i<n; i++){ if(arg[i]%k== 0 ){ System.out.println(arg[i]);} else{ System.out.println("X");} } } }
public class { public static void main(String[] arg s) { Scanner ent = new Scanner(System .in); System.out.println("Digite la ca ntidad de soldados de cada pueblo:"); int arreglo1[],arreglo2[],n,cont = 0 ; n = ent.nextInt(); arreglo1 = new int [n]; arreglo2 = new int [n]; System.out.println("Pueblo 1:"); for(int num= 0 ;num<n;num++){ arreglo1[num]=ent.nextInt(); } System.out.println("Pueblo 2:"); for(int num= 0 ;num<n;num++){ arreglo2[num]=ent.nextInt(); } for(int num= 0 ;num<n;num++){ if(arreglo1[num]!=arreglo2[n um]){ cont ++; } }System.out.println("Pueblos en peligro:"+cont); } }
public class { public static void main(String[] args) { Scanner entrada = new Scanner(System.in); int arreglo[],nElementos,aux; System.out.println("Ingrese el numero de elementos a ordenar:"); nElementos = entrada.nextInt(); arreglo = new int[nElementos]; for(int i= 0 ;i<nElementos;i++){ System.out.print((i+ 1 )+". Digite un numero: "); arreglo[i] = entrada.nextInt(); } for(int i= 0 ;i<(nElementos- 1 );i++){ for(int a= 0 ;a<(nElementos- 1 );a++){ if(arreglo[a]>arreglo[a+ 1 ]){ aux = arreglo[a]; arreglo[a] = arreglo[a+ 1 ]; arreglo[a+ 1 ] = aux; }}} System.out.println("Edades:"); for(int i= 0 ;i<(nElementos- 1 );i++){ if(arreglo[i]!=arreglo[i+ 1 ]){ System.out.println(arreglo[i]);} }System.out.println(arreglo[nElementos- 1 ]); } }