Escolar Documentos
Profissional Documentos
Cultura Documentos
*/
package ejercicio1;
/**
* @author Patow
*/
import java.util.Scanner;
float media = 0;
int c,j;
c= s.nextInt();
if (c%2 != 0){
for(j=1;j<=c;j=j+1)
System.out.println("Ingrese el valor");
M[j]=s.nextFloat();
for(j=1;j<=c;j++)
media+=M[j];
media=media/c;
}
5.-Se tienen los nombres de los N alumnos de una escuela, adems de su
promedio general. Realice un algoritmo para capturar esta informacin, la
cual se debe almacenar en arreglos, un vector para el nombre y otro para el
promedio, despus de capturar la informacin se debe ordenar con base en
su promedio, de mayor a menor, los nombres deben corresponder con los
promedios. Realice el algoritmo y represntelo mediante el diagrama de flujo,
el pseudocdigo y el diagrama N/S
/*
*/
package ejercicio.pkg2;
import java.util.Scanner;
/**
* @author Patow
*/
int n,j,i;
int mayor;
n=s.nextInt();
nombres[i]=s.nextLine();
notas[i]=s.nextInt();
auxiliar[i] = notas[i];
mayor = auxiliar[j];
auxiliar[j] = auxiliar[j+1];
auxiliar[j+1] = mayor;
if(notas[j] == auxiliar[i]){
}
}
9.-Elabore un algoritmo que lea los datos de una matriz cuadrada de tamao
N y realice las siguientes operaciones:
*/
package ejercicio.pkg9;
import java.util.Scanner;
/**
* @author Patow
*/
/**
*/
public static void main(String[] args) {
int i,j,f;
f=s.nextInt();
for(i=1;i<=f;i++)
for(j=1;j<=f;j++)
M[i][j]=s.nextInt();
System.out.println("\n");
for(i=1;i<=f;i++)
for(j=1;j<=f;j++)
System.out.println("%i "+M[i][j]);
System.out.println("\n");
int aux=0;
for(i=1;i<=f;i++)
for(j=1;j<=f;j++)
if(i==j)
{
aux=aux+M[i][j];
int aux1=0;
for(i=1;i<=f;i++)
for(j=1;j<=f;j++)
if(M[i][j]==0)
aux1=aux1+1;
int a;
for (i=1;i<=f;i++)
P[i]=M[i][i];
a=f;
for (i=1;i<=f;i++)
S[i]=M[i][a];
a--;
a=f;
for (i=1;i<=f;i++)
M[i][i]=S[i];
M[i][a]=P[i];
a--;
for(i=1;i<=f;i++)
for(j=1;j<=f;j++)
System.out.println("\n");
System.out.println("\n");
aux=0;
for (i=1;i<=f;i++)
for(j=1;j<=f;j++)
if(M[i][j]>aux)
aux=M[i][j];
}
System.out.println("El mayor nmero es %i"+ aux);
*/
package ejercicio.pkg13;
/**
* @author Patow
*/
/**
*/
int i,j,min,sum,can;
int a[][]= {{0, 15, 20, 25, 30, -4, -4, 5, 4, 9, -3, 4},{4, 1, 2, 5, 32, 3,
23, 51, 41, 3, -31, 43}, {10, -15, 24, 25, 2, 23, 4, 5, 67, 95, 43, 11},{4,
-11, 3, 25, 3, -42, -49, 57, 45, 99, -30, 77},{3, 90, 68, 255, -89, 79,
122, 55, 59, 93, 32, -67},{7, 87, -35, 205, -32, 49, 37, 78, 45, -47, 49,
-53},{1, -45, -61, 501, -8, 81, 12, 512, 15, -19, 29, 27},{-8, -53, 26,
11, -31, 28, 27, 30, -37, -41, 46, -49},{-1, 32, 29, -145, -67, -69, -87, -
97, 91, 56, 94, -17},{7, 87, -37, 45, -76, -77, 87, 85, 94, -39, 31, 84},{9,
1, -49, 912, 46, 94, -35, -55, -57, 84, 911, 4},{-4, -89, -43, -12, -97, -
87, -33, -76, -90, 13, 42, 85},{4, 4, 20, -45, 31, -45, -46, 57, 48, 91, -
23, 74},{-1, -5, 20, 51, 3, -5, -9, 88, -99, -66, 55, -12},{3, 77, 20, 53,
-32, -67, -98, -34, -34, -12, -97, -45}};
min=a[0][0];
sum=0;
can=0;
for(i=0;i<15;i++)
for(j=0;j<12;j++)
System.out.println(a[i][j]);
if(min>a[i][j])
min=a[i][j];
if(i<=4)
sum=sum+a[i][j];
if((i>=4)&&(i<=8))
if(a[i][j]<0)
can=can+1;
}
}
//---------------
17. Una compaa de transporte cuenta con cinco choferes, de los cuales
se conoce: nombre, horas trabajadas cada da de la semana (seis das) y
sueldo por hora. Realice un algoritmo que:
/*
*/
package javaapplication5;
import java.util.Scanner;
/**
* @author Patow
*/
val1=s.nextInt();
for(int i=1;i<=5;i++)
trab[i]=s.nextLine();
for(int j=1;j<=6;j++)
val2=val2+ hor[i][j];
f[i]=val2*val1;
c[i]=val2;
val3=val3+c[i];
val2=0;
if(hor[i][1]>val4)
val4=hor[i][1];
val5=i;
21. Escribir el cdigo de un mtodo que devuelva una palabra (un vector
de caracteres). El mtodo debe generar un vector de caracteres aleatorios,
recibiendo como argumentos: la longitud del vector y el rango de valores
permitidos (rango al que deben pertenecer los caracteres aleatorios que se
elijan como valores).
/*
* To change this license header, choose License Headers in Project
Properties.
*/
package pkg21;
/**
* @author Patow
*/
/**
*/
String [] abecedario = {"A", "B", "C", "D", "E", "F", "G", "H", "I", "J",
System.out.println(
abecedario[numRandon]+abecedario[numRandon1]+abecedario[numRando
n2]+abecedario[numRandon3]+abecedario[numRandon4]+abecedario[num
Randon5] );