You are on page 1of 14

1.- Sr tiene un conjunto de servidores del proyecto TIC UMSA . Cada servidor con un conjunto de terminales. a.

.- Mostrar el nombre del servidor que tiene ms terminales. b.- Mostrar cuantos y cuales son las terminales que tienen Sistemas Operativos X y el servidor al que pertenece. c.- Eliminar las terminales con Velocidad de Procesador X de servidor IP Y. d.- Adicionar un nuevo servidor M con N terminales respetando el orden alfabtico por nombre de servidor (sumiendo que la lista de servidores ya esta ordenado). e.- Mostrar los datos del servidor que tiene la menor cantidad de terminales con HP menor o igual a la capacidad. class manejolistamultiple { public static void proceso1 (LSNormalS a) { NodoS r = a.pm; int may = 0, c; while (r != null) { LSNormalT b = new LSNormalT (); b.p = r.s; c = b.nronodos (); if (c > may) may = c; r = r.sig; } r = a.pm; while (r != null) { LSNormalT b = new LSNormalT (); b.p = r.s; c = b.nronodos (); if (c == may) Syste (r.serv); r = r.sig; } } public static void proceso2 (LSNormalS a, String x) { NodoS r = a.pm; int c = 0; while (r != null)

{ LSNormalT b = new LSNormalT (); b.p = r.s; NodoT r2; r2 = b.p; while (r2 != null) { if (x.compareTo (r2.so) == 0) { c++; r2.mostrar (); System.out.println (r.serv); } r2 = r2.sig; } r = r.sig; } Syste("Numero de terminales que tiene x S.O. " + c); } public static void proceso3 (LSNormalS a, String x, int y) { NodoS r = a.pm; int i, n; while (r != null) { if ((r.ip).compareTo (x) == 0) { LSNormalT b = new LSNormalT (); b.p = r.s; NodoT r3 = null, n4; NodoT r2 = b.p; i = 1; n = b.nronodos (); while (r2 != null) { if ((r2.vp) == y) { if (i == 1) { n4 = b.eliprimero (); r2 = b.p; i = 1; } else { if (i == n) {

b.eliultimo (); r2 = null; } else { r3.sig = r2.sig; r2 = r3.sig; } } n = b.nronodos (); } else { r3 = r2; i++; r2 = r2.sig; } } } r = r.sig; } } public static void proceso5 (LSNormalS a, int x) { NodoS r = a.pm; int men = 999999, c = 0; NodoT r2; while (r != null) { LSNormalT b = new LSNormalT (); b.p = r.s; r2 = b.p; while (r2 != null) { if ((r2.hd) <= x) c++; r2 = r2.sig; } if (c < men) men = c; c = 0; } r = a.pm; int c2 = 0; while (r != null) {

LSNormalT b = new LSNormalT (); b.p = r.s; r2 = b.p; while (r2 != null) { if ((r2.hd) <= x) c2++; r2 = r2.sig; } if (c2 == men) System.out.println (r.serv); c2 = 0; r = r.sig; } } public static void main (String args []) { String x; LSNormalS A = new LSNormalS (); int n, i; Syste("Numero de Servidores: "); n = Leer.datoInt (); A.leer2 (n); A.mostrar (); Syste("Inciso A)====>"); proceso1 (A); Syste("Inciso B)====>"); Syste("Leer el nombre de un Sistema Operativo"); x = Leer.Cadena (); proceso2 (A, x); Syste("Inciso C)====>"); Syste("Leer el IP "); x = Leer.Cadena (); Syste("Leer la velocidad del procesador"); i = Leer.datoInt (); proceso3 (A, x, i); A.mostrar (); Syste("Inciso E)====>"); Syste("Leer una capacidad x"); i = Leer.datoInt (); proceso5 (A, i); } } //****************************** class LSNormalS extends ListaSimpleS { void llevafinal ()

{ NodoS x, r; r = pm.sig; x = pm; pm = r; while (r.sig != null) r = r.sig; r.sig = x; x.sig = null; } } //************* class NodoS { String serv,ip,fac; NodoS sig; NodoT s; NodoS () { s = null; sig = null; } void leer () { Syste("Nombre_Servidor: "); serv = Leer.Cadena (); Syste("IP: "); ip = Leer.Cadena (); Syste("Nombre_Facultad: "); fac = Leer.Cadena (); } void mostrar () { Syste("Nombre_Servidor: " + serv); Syste("IP: " + ip); Syste("Nombre_Facultad: " + fac); } } //***************** class NodoT { String so, nomt; int vp, hd; NodoT sig; NodoT () { sig = null;

so = "xxx"; nomt = "yyy"; vp = 80; hd = 45; } void leer () { Syste("Sistema_Operativo: "); so = Leer.Cadena (); Syste("Nombre_Terminal: "); nomt = Leer.Cadena (); Syste("Velocidad_Procesador: "); vp = Leer.datoInt (); Syste("HD: "); hd = Leer.datoInt (); } void mostrar () { Syste("Sistema_Operativo: " + so); Syste("Nombre_Terminal: " + nomt); Syste("Velocidad_Procesador: " + vp); Syste("HD: " + hd); } } //**************************** 3.- SUPERMERCADO Dado un supermercado que tiene sus distintas sucursales i tiene la siguiente estructusa de datos. La lista principal contiene a las sucursales (nombre, ubicacin, enlace a la lista de emplesdos). Cada empleado (nombre , nro de identificadcaion, enlace a su lista de ventas ) esta en la sub-lista empleados. La sub-sub-lista pertenece a las ventas (dia, producto, cantidad) que hiciedon cada empleado durante una semana . a.- Hallar la cantidad que se vendi durante una semana del producto X en todo el supermercado. b.- Que empleados no vendieron nada en el dia jueves y a que sucursal pertenece. c.- Cual es la mejor sucursal (vendido mas productos). d.- Se tiene dos empleados distintos A y B. Cuales sonlos productos iguales que vendieron no importando la cantidad sino el producto. e.- Cual es la cantidad que se vendi del producto X en el dia Y. f.- Cual o cuales con las sucursales que cuentan con el menor numero de empleados. g.- Entre dos sucursales cual es la que vendi mas el dia X. h.- Quien es el mejor empleado de la empresa. i.- Cual es el producto estrella del supermercado. class principal { public static void main (String [] args)

{ LSNormalLP a = new LSNormalLP (); Syste("Intr el numero de sucursales "); int n = Leer.datoInt (); a.leer2 (n); a.mostrar (); Syste ("SOLUCION ==> A"); a.solucion_a ("X"); Syste("SOLUCION ==> B"); a.solucion_b (); Syste ("SOLUCION ==> C"); a.solucion_c (); Syste("SOLUCION ==> E"); a.solucion_e ("X", "LUNES"); Syste("\nSOLUCION ==> F"); a.solucion_f (); Syste("SOLUCION ==> G"); a.solucion_g ("LUNES"); } } //************************ class LSNormalLP extends ListaSimpleLP { //hallar la cantodad que se vendioo durante una semana del producto X // en todo el supermercado void solucion_a (String w) { int cont = 0; Nodo_LP x = pm; while (x != null) { Nodo_LE y = x.le; int c = 0, l = 0, m = 0, mi = 0, j = 0, v = 0, s = 0, d = 0; while (y != null) { Nodo_LV z = y.lv; while (z != null) { if (z.producto.equals (w)) { if ("LUNES".equals (z.dia)) l = 1; if ("MARTES".equals (z.dia)) m = 1; if ("MIERCOLES".equals (z.dia)) mi = 1; if ("JUEVES".equals (z.dia))

j = 1; if ("VIERNES".equals (z.dia)) v = 1; if ("SABADO".equals (z.dia)) s = 1; if ("DOMINGO".equals (z.dia)) d = 1; c++; } z = z.sig; } y = y.sig; } int di = l + m + mi + j + v + s + d; if (di == 7) { cont = cont + c; di = 0; System.out.println ("Durante la semana se vendio " + c); } x = x.sig; } } //Que empleados no vendieron nada en el dia //jueves y a que sucursal pertenece ? void solucion_b () { int sw = 0; Nodo_LP x = pm; while (x != null) { Nodo_LE y = x.le; while (y != null) { Nodo_LV z = y.lv; while (z != null) { if (z.dia.equals ("JUEVES")) sw = 0; else sw = 1; z = z.sig; } if (sw == 1) { System.out.println ("EL EMPLEADO QUE NO VENDIO NADA EL DIA JUEVES ES "); System.out.println ("LA SUCURSAL ES => " + x.nombre);

System.out.println ("EL EMPLEADO ES => " + y.nombreE); } y = y.sig; } x = x.sig; } } //CUAL ES LA MEJOR SUCURSAL (VENDIO MAS PRODUCTO ) void solucion_c () { int men = Integer.MIN_VALUE; Nodo_LP x = pm; while (x != null) { Nodo_LE y = x.le; int em = 0; while (y != null) { Nodo_LV z = y.lv; int c = 0; while (z != null) { c = c + z.cantidad; z = z.sig; } em = em + c; y = y.sig; } if (em > men) men = em; x = x.sig; } x = pm; while (x != null) { Nodo_LE y = x.le; int em = 0; while (y != null) { Nodo_LV z = y.lv; int c = 0; while (z != null) { c = c + z.cantidad; z = z.sig;

} em = em + c; y = y.sig; } if (em == men) { System.out.println ("LA MEJOR SUCURSAL ES => " + x.nombre); } x = x.sig; } } //Se tiene dos empleados distintos Ay B. Cuales son los productos //iguales que vendieron no importa la cantidad sino el producto void solucion_d () { int sw = 0; Nodo_LP x = pm; while (x != null) { Nodo_LE y = x.le; while (y != null) { Nodo_LV z = y.lv; while (z != null) { z = z.sig; } y = y.sig; } x = x.sig; } } //Cual es la cantidad que se vendio el producto X en el dia Y void solucion_e (String p, String d) { Nodo_LP x = pm; while (x != null) { int can = 0; Nodo_LE y = x.le; while (y != null) { Nodo_LV z = y.lv; while (z != null) { if (z.producto.equals (p) && z.dia.equals (d)) can++;

z = z.sig; } y = y.sig; } Syste ("LA CANTIDAD QUE SE VENDIO DE LS "); Syste ("LA SUCURSAL " + x.nombre); Syste ("PRODUCTO " + p); Syste ("EL DIA " + d); Syste ("TOTAL ES => " + can); x = x.sig; } } // CUAL O CUALES SON LAS SUCURSALES QUE CUENTA CON EL MENOR // NUMERO DE EMPLEADOS void solucion_f () { int men = Integer.MAX_VALUE; Nodo_LP x = pm; while (x != null) { int ne = 0; Nodo_LE y = x.le; while (y != null) { ne++; y = y.sig; } if (ne <= men) men = ne; x = x.sig; } x = pm; while (x != null) { int ne = 0; Nodo_LE y = x.le; while (y != null) { ne++; y = y.sig; } if (ne == men) Syste ("LA SUCURSAL CON MENOR NRO DE EMPLEADOS ES " + x.nombre); x = x.sig; } } // Entre dos sucursales cual es la que vendio mas el dia X

void solucion_g (String d) { Nodo_LP x = pm; int mas = Integer.MIN_VALUE; while (x != null) { Nodo_LE y = x.le; int nv = 0; while (y != null) { Nodo_LV z = y.lv; while (z != null) { if (z.dia.equals (d)) nv++; z = z.sig; } y = y.sig; } if (mas <= nv) mas = nv; x = x.sig; } x = pm; while (x != null) { Nodo_LE y = x.le; int nv = 0; while (y != null) { Nodo_LV z = y.lv; while (z != null) { if (z.dia.equals (d)) nv++; z = z.sig; } y = y.sig; } if (mas == nv) System.out.println ("LA SUCURSAL QUE VENDIO MAS ES " + x.nombre); x = x.sig; } } } //************ class Nodo_LP

{ String nombre, ubicacion; Nodo_LP sig; Nodo_LE le; Nodo_LP () { sig = null; le = null; } void leer () { Syste ("Nombre de la sucursal nombre = Leer.Cadena (); Syste ("Ubicacion de la sucursal ubicacion = Leer.Cadena (); } void mostrar () { Syste ("Nombre de la sucursal Syste ("Ubicacion de la sucursal }

: "); : ");

: " + nombre); : " + ubicacion);

} class Nodo_LE { String nombreE; int nroidentificacion; Nodo_LE sig; Nodo_LV lv; Nodo_LE () { sig = null; lv = null; } void leer () { Syste ("Nombre del empleado : "); nombreE = Leer.Cadena (); Syste ("ID del empleado : "); nroidentificacion = Leer.datoInt (); } void mostrar () { Syste ("Nombre del empleado : " + nombreE); Syste ("ID del empleado : " + nroidentificacion); } } class Nodo_LV

{ String dia, producto; int cantidad; Nodo_LV sig; Nodo_LV () sig = null; void leer () { Syste ("Dia de venta : "); dia = Leer.Cadena (); Syste("Producto de venta : "); producto = Leer.Cadena (); Syste ("Cantidad del vemta : "); cantidad = Leer.datoInt (); } void mostrar () { Syste("Dia de venta : " + dia); Syste ("Producto de venta : " + producto); Syste ("Cantidad del vemta : " + cantidad); } }

You might also like