Estas son las escuelas y colegios que tendrán modalidad no presencial este lu...
Ejercicios resuletos de programacion
1. EJERCICIOS RESULETOS DE
PROGRAMACION
Generar la siguiente serie:
2, 4, 8, 16, 32, 64, 128, 256, ...
3, 9, 27, 81, 243, 729, 2187, ...
//William Lozano
package wlpractica4;
import java.util.Scanner;
class wlejercicio1 {
public static void main (String args [])
{
Scanner datos=new Scanner (System.in);
int num, contador = 1, serie = 2;
System.out.print (" INGRESE LA CANTIDAD DE
TERMINOS : ");
num = datos.nextInt();
while (contador <= num)
{
System.out.print ("," + serie);
serie *= 2;
contador++;
}
}
}
//William Lozano
2. package wlpractica4;
import java.util.Scanner;
class wlejercicio2 {
public static void main (String args [])
{
Scanner datos=new Scanner (System.in);
int num, contador = 1, serie = 3;
System.out.print (" INGRESE LA CANTIDAD DE
TERMINOS : ");
num = datos.nextInt();
while (contador <= num)
{
System.out.print ("," + serie);
serie *= 3;
contador++;
}
}
}
//William Lozano
package wlpractica4;
import java.util.Scanner;
class wlejercicio2 {
public static void main (String args [])
{
Scanner datos=new Scanner (System.in);
3. int num, contador = 1, serie = 3;
System.out.print (" INGRESE LA CANTIDAD DE
TERMINOS : ");
num = datos.nextInt();
while (contador <= num)
{
System.out.print ("," + serie);
serie *= 3;
contador++;
}
}
}
Se introduce a través del teclado dos vectores A de n elementos y B
de m elementos. Fusionar los dos vectores en un tercer vector e
imprimir. (si existen elementos repetidos solo debe mantenerse una
vez el elemento).
//WILLIAM LOZANO
package wlpractica11;
import java.util.Scanner;
class ejercicio1 {
public static void main(String[] args) {
Scanner datos = new Scanner(System.in);
int [] vectorA=new int [50];
int [] vectorB=new int [50];
int elemt,i,num, j, contador = 0,dir;
System.out.print("CREACION DE DOS VECTORES Y
FUCIONARLOS EN UN SOLO VECTOR");
System.out.println("n");
System.out.print("VECTOR 1 ");
4. System.out.println("n");
System.out.print("INGRESE EL TAMAÑO DEL VECTOR 1:");
System.out.println("n");
num = datos.nextInt();
for (i = 0; i < num; i++) {
System.out.println("INGRESE LOS ELEMENTOS: "+i);
vectorA [i] = datos.nextInt();
}
System.out.print("VECTOR 2 ");
System.out.println("n");
System.out.print("INGRESE EL TAMAÑO DEL VECTOR 2:");
System.out.println("n");
elemt = datos.nextInt();
for (i = 0; i < elemt; i++) {
System.out.println("INGRESE LOS ELEMENTOS: "+i );
vectorB [i] = datos.nextInt();
}
dir = num + elemt;
int[]vectorRaux = new int[dir];
for (i = 0; i < num; i++) {
vectorRaux[i] = vectorA[i];
}
for (i = num; i < dir; i++) {
vectorRaux[i] = vectorB[i-num];
}
for (i = 0; i < dir - 1; i++) {
for (j = i + 1; j < dir; j++) {
if (vectorRaux[i] == vectorRaux[j]) {
vectorRaux[j] = -99999999;
}
}
}
for (i = 0; i < dir; i++) {
if (vectorRaux[i] != -99999999) {
contador++;
}
}
int[] vectorConbi = new int[contador];
j = 0;
for (i = 0; i < dir; i++) {
if (vectorRaux[i] != -99999999) {
vectorConbi[j] = vectorRaux[i];
j++;
}
}
5. System.out.printf(" LA COMBINACION DE AMBOS VECTORES
ES:n");
for (i = 0; i < contador; i++) {
System.out.printf("%s ", vectorConbi[i]);
}
System.out.println("n");
System.out.println("n");
System.out.println("n");
}
}
cicios con vectores
1. Ingrese n elementos en un vector y en un vector resultante ordene
de menor a
Mayor.
/William Lozano
package wlpractica9;
import java.util.Scanner;
class ejercicio1 {
public static void main(String[] args) {
Scanner datos = new Scanner(System.in);
int [] A=new int [50];
int i, num,j,aux;
System.out.print("************INGRESE EL TAMAÑO DEL
VECTOR*****************n");
num=datos.nextInt();
for(i=0; i<num; i++)
{
System.out.print("************INGRESE EL NUMERO
*********"+i+": ");
7. }
2. Ingrese n elementos en un vector y en un vector resultante
coloque solo los
Elementos que sean divisibles para 3.
//William Lozano
package wlpractica9;
import java.util.Scanner;
class ejercicio2 {
public static void main(String[] args) {
Scanner datos= new Scanner(System.in);
int[] vector=new int[100];
int x,i;
System.out.println("*******INGRESE EL TAMAÑO DE VECTOR A
DIGITAR**********");
x=datos.nextInt();
for(i=0;i<x;i++)
{
System.out.println("***********INGRESAR EL NUMERO
************");
vector[i]=datos.nextInt();
}
System.out.println("*********LOS NUMEROS DIVISIBLES
PARA 3 SON LOS SIGUIENTES**** :");
for(i=0;i<x;i++)
{
if(vector[i]%3==0)
8. {
System.out.println(vector[i]);
}
}
}
}
3. Ingrese n elementos en un vector y un vector resultante coloque
solo los números
Primos.
//William Lozano
package wlpractica9;
import java.util.Scanner;
class ejercicio3 {
public static void main(String[] args) {
Scanner datos= new Scanner(System.in);
int[] vect=new int[100];
int[] vect2=new int[100];
int i,num,cont,j,mod,a=0;
System.out.println("********************INGRESE EL
TAMAÑO DEL VECTOR A DIGITAR*************");
num=datos.nextInt();
for(i=0;i<num;i++)
{
System.out.println("***************INGRESE EL
NUMERO********");