gonzalob

Untitled

Apr 16th, 2020
318
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.95 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4.  
  5. int main()
  6. {
  7.     int idEmpleados [100] = {0};
  8.     int idEmpleadosPrimos [100] = {0};
  9.     char mander = 's';
  10.     int validos = 0;
  11.     int valor = 1;
  12.     int suma = 0;
  13.     int limite = 5;
  14.  
  15.     while (validos < limite)
  16.     {
  17.         idEmpleados[validos] = valor;
  18.         valor++;
  19.         validos++;
  20.     }
  21.     for (int i=0;i<validos;i++)
  22.     {
  23.         printf("%d arreglo[%d] --> %d\n",i,i+1,idEmpleados[i]);
  24.     }
  25. /*
  26. Dado un el vector {1,5,6,7,8} escribir un programa
  27. que genere otro vector con
  28. la suma del contenido de todo los elementos anteriores al índice actual: {1,6,12,19,27}.
  29. */
  30.  
  31.  idEmpleadosPrimos[0] = idEmpleados[0];
  32.  for (int i=1;i<validos;i++)
  33.     {
  34.  
  35.  
  36.             idEmpleadosPrimos[i] = idEmpleadosPrimos[i-1] +idEmpleados[i];
  37.  
  38.  
  39.     }
  40.  
  41.     printf("\n");
  42.  
  43.      for (int i=0;i<validos;i++)
  44.     {
  45.         printf("%d arreglo[%d] --> %d\n",i,i+1,idEmpleadosPrimos[i]);
  46.     }
  47.  
  48.  
  49. }
Advertisement
Add Comment
Please, Sign In to add comment