Ledger Nano X - The secure hardware wallet
SHARE
TWEET

Guia 5 - Ej1 [C]

Ramiro-Pruis Apr 6th, 2020 (edited) 285 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. program G05Ej1;
  2. type
  3.   TV=array[1..15] of integer;
  4. procedure LeeVec(var A:TV;N:byte); //Carga los datos en el vector
  5. var
  6.   i:byte;
  7. begin
  8.   for i:=1 to N do
  9.   begin
  10.     Write('Ingrese un valor: ');
  11.     readln(A[i]);
  12.   end;
  13. end;
  14.  
  15. function SumaVec(A:TV;N:byte):integer; //Suma los elementos del vector
  16. var
  17.   i:byte;
  18.   aux:integer;
  19. begin
  20.   aux:=0;
  21.   for i:=1 to N do
  22.   begin
  23.     aux:=aux+A[i];
  24.   end;
  25.   SumaVec:=aux;
  26. end;
  27.  
  28. procedure MaxMin(A:TV;N:byte;var max,min:integer);     //Encuentra valor max y min
  29. var
  30.   i:byte;
  31. begin
  32.   max:=0;min:=99999999;
  33.   for i:=1 to N do
  34.   begin
  35.     if A[i]>max then
  36.       max:=A[i];
  37.     if A[i]<min then
  38.       min:=A[i];
  39.   end;
  40. end;
  41.  
  42. procedure permutar(A:TV;var B:TV;N:byte);   //Permuta los valores de A en B
  43. var
  44.   aux:integer;
  45.   i,j:byte;
  46. begin
  47.   aux:=A[N];
  48.   j:=N;
  49.   for i:=1 to N do
  50.   begin
  51.     B[i]:=aux;
  52.     J:=J-1;
  53.     aux:=A[J];
  54.   end;
  55. end;
  56.  
  57. procedure EscVec(A:TV;N:byte);  //Escribe el vector en paantalla
  58. var
  59.   i:byte;
  60. begin
  61.   for i:=1 to N do
  62.   begin
  63.     write(A[i],' - ');
  64.   end;
  65. end;
  66.  
  67. var
  68.   max,min:integer;
  69.   VecA,VecB:TV;
  70.   N:byte;
  71. begin //Programa Principal
  72.   repeat
  73.   writeln('Ingrese cuantos valores va a ingresar <=15 ');readln(N);
  74.   until n<=15 ;
  75.   leeVec(VecA,N);
  76.   writeln('Su suma es: ',SumaVec(VecA,N));
  77.   MaxMin(VecA,N,max,min);
  78.   writeln('Su valor maximo es ',max,' y su valor minimo ',min);
  79.   permutar(VecA,VecB,N);
  80.   write('Los valores de B son ');EscVec(VecB,N);
  81.   readln();
  82. end.
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top