Advertisement
Guest User

Untitled

a guest
Aug 12th, 2017
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pascal 4.09 KB | None | 0 0
  1. program grandt;
  2.  
  3. uses AyPDT, CRT;
  4.  
  5. const
  6.     FECHAS_TORNEO = 19;
  7.     EQUIPOS = 20;
  8.     JUGADORES = 623;
  9.     MAX_USUARIOS = 10;
  10.     PRESUPUESTO = 60000000;
  11.     SEPARADORH = '--------------------------------------------------------------------------------';
  12.  
  13. var
  14.     jugadoress:tListaJugadores;
  15.     jugador:tJugador;
  16.     posicion:tPosicion;
  17.     seleccion:byte;
  18.     i:integer;
  19.  
  20. function OrdenarSecuencial(mayoramenor:boolean;eleccion:string):tListaJugadores;
  21. //Ordena la Lista de Jugadores segun un parametro, 0 en el argumento1 "de menor a mayor, 1 en el argumento1 "de mayor a menor".
  22.     var
  23.         aux : tJugador;
  24.         i,j : integer;
  25.    
  26.     begin
  27.         if eleccion='precio' then
  28.             for i:=1 to JUGADORES-1 do
  29.                 for j:=i+1 to JUGADORES do
  30.                     if mayoramenor then
  31.                         begin
  32.                         if jugadoress[i].precio<jugadoress[j].precio then
  33.                             begin
  34.                             aux:=jugadoress[i];
  35.                             jugadoress[i]:=jugadoress[j];
  36.                             jugadoress[j]:=aux;
  37.                             end;
  38.                         end
  39.                     else
  40.                         begin
  41.                         if jugadoress[i].precio>jugadoress[j].precio then
  42.                             begin
  43.                             aux:=jugadoress[i];
  44.                             jugadoress[i]:=jugadoress[j];
  45.                             jugadoress[j]:=aux;
  46.                             end;
  47.                         end;
  48.        
  49.         if eleccion='id' then          
  50.             for i:=1 to JUGADORES-1 do
  51.                 for j:=i+1 to JUGADORES do
  52.                     if mayoramenor then
  53.                         begin
  54.                         if jugadoress[i].precio<jugadoress[j].ID then
  55.                             begin
  56.                             aux:=jugadoress[i];
  57.                             jugadoress[i]:=jugadoress[j];
  58.                             jugadoress[j]:=aux;
  59.                             end;
  60.                         end
  61.                     else
  62.                         begin
  63.                         if jugadoress[i].precio>jugadoress[j].ID then
  64.                             begin
  65.                             aux:=jugadoress[i];
  66.                             jugadoress[i]:=jugadoress[j];
  67.                             jugadoress[j]:=aux;
  68.                             end;
  69.                         end;           
  70.         OrdenarSecuencial:=jugadoress;
  71.        
  72.     end;
  73.    
  74.        
  75. procedure Imprimir_Todos_Los_Jugadores();
  76.     var
  77.         i,j : integer;
  78.         salir : string;
  79.    
  80.     begin
  81.     clrscr();
  82.     i:=1;
  83.     salir:='';
  84.     while (salir<>'q') do
  85.         begin
  86.         clrscr();
  87.         writeln(SEPARADORH);
  88.         writeln('ID':3,' ','APELLIDO Y NOMBRE':28,'  ','PRECIO':8,' ','EQUIPO':14,'    ','POSICION');
  89.         writeln(SEPARADORH);
  90.         j:=1;
  91.        
  92.         while (j<=18) do
  93.             begin
  94.             if i<=JUGADORES then
  95.                 writeln(jugadoress[i].id:3,' ',jugadoress[i].nombre:28,'  ',(jugadoress[i].precio/1000000):8:1,'M ',jugadoress[i].equipo_real:14,'    ',jugadoress[i].posicion:15)
  96.             else
  97.                 writeln('');
  98.             inc(i);
  99.             inc(j);
  100.             end;
  101.         writeln(SEPARADORH);
  102.         readln(salir);
  103.         if (i>JUGADORES) then
  104.             i:=1;
  105.         end;
  106.     end;
  107.  
  108. procedure Imprimir_Jugadores_De_Posicion(posicion:tPosicion);
  109.     var
  110.         i,j : integer;
  111.         salir : string;
  112.    
  113.     begin
  114.     clrscr();
  115.     i:=1;
  116.     salir:='';
  117.     while (salir<>'q') do
  118.         begin
  119.         clrscr();
  120.         writeln('ID':3,' ','APELLIDO Y NOMBRE':28,'  ','PRECIO':8,' ','EQUIPO':14,'    ','POSICION');
  121.         writeln(SEPARADORH);
  122.         j:=1;
  123.        
  124.         while (j<=18) do
  125.             begin
  126.             if i<=JUGADORES then
  127.                 begin
  128.                 if jugadoress[i].posicion=posicion then
  129.                     begin
  130.                     writeln(jugadoress[i].id:3,' ',jugadoress[i].nombre:28,'  ',(jugadoress[i].precio/1000000):8:1,'M ',jugadoress[i].equipo_real:14,'    ',jugadoress[i].posicion:15);
  131.                     inc(j);
  132.                     end;
  133.                 end
  134.             else
  135.                 begin
  136.                 writeln('');
  137.                 inc(j);
  138.                 end;
  139.            
  140.             inc(i);
  141.                
  142.             end;
  143.  
  144.         if (i>JUGADORES) then
  145.             begin
  146.             //writeln('dfdfsdfsdfsdfsdfsdf',i);
  147.             i:=1;
  148.             end;
  149.        
  150.         writeln(SEPARADORH);
  151.         readln(salir);
  152.         end;
  153.     end;
  154.  
  155. begin
  156.    
  157.     for i:=1 to JUGADORES do
  158.         begin
  159.         obtenerJugador(i, jugador);
  160.         jugadoress[i]:=jugador;
  161.         end;
  162.    
  163.     writeln('Eliga el numero de lista');
  164.     writeln('1- Todos los jugadores ordenados por equipo');
  165.     writeln('2- Todos los jugadores ordenados por precio');
  166.     writeln('3- Jugadores de una Posicion ordenados por equipo');
  167.     writeln('4- Jugadores de una Posicion ordenados por precio');
  168.    
  169.     readln(seleccion);
  170.     case(seleccion) of
  171.     1:
  172.         begin
  173.         OrdenarSecuencial(true,'id');
  174.         Imprimir_Todos_Los_Jugadores();
  175.         end;
  176.     2:
  177.         begin
  178.         OrdenarSecuencial(true,'precio');
  179.         Imprimir_Todos_Los_Jugadores();
  180.         end;
  181.     3:
  182.         begin
  183.         writeln('Ingrese ARQUERO DEFENSOR MEDIOCAMPISTA o DELANTERO');
  184.         OrdenarSecuencial(true,'id');
  185.         readln(posicion);
  186.         Imprimir_Jugadores_De_Posicion(posicion);
  187.         end;
  188.     4: 
  189.         begin
  190.         writeln('Ingrese ARQUERO DEFENSOR MEDIOCAMPISTA o DELANTERO');
  191.         OrdenarSecuencial(true,'precio');
  192.         readln(posicion);
  193.         Imprimir_Jugadores_De_Posicion(posicion);
  194.         end;
  195.     end
  196. end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement