Advertisement
lencinasalejo

vectoresej2

May 19th, 2018
356
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.40 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4. int EsLegajoValido(int, int);
  5. void CargaLegajo (float [], int);
  6. float SuelMax (float[], int);
  7. void MostrarIgualQue (float[], int, float);
  8.  
  9. int main()
  10. {
  11. float VEmpleados[100]={0}, maximo;
  12. int ce=100;
  13. //printf ("Ingrese la cantidad de empleados: ");
  14. //scanf ("%d", &ce);
  15. CargaLegajo(VEmpleados, ce);
  16. maximo=SuelMax(VEmpleados, ce);
  17. MostrarIgualQue(VEmpleados, ce, maximo);
  18. return 0;
  19.  
  20. }
  21. int EsLegajoValido(int leg, int ce){
  22. if (leg>0 && leg<=ce){
  23.     return 1;
  24. }else{return 0;}
  25. }
  26. void CargaLegajo(float v[], int ce){
  27.     int leg;
  28.     float sueldo;
  29. do{
  30.     printf ("Ingrese un numero de legajo: ");
  31.     scanf ("%d", &leg);
  32.     if (EsLegajoValido(leg, ce)==1){
  33.         printf("Ingrese su sueldo: ");
  34.         scanf ("%f", &sueldo);
  35.         v[leg-1]=sueldo;
  36.     }else{
  37.         if(leg==0){
  38.             printf("Fin del programa\n");
  39.         }else{
  40.     printf ("El legajo no es valido \n");}
  41.     }
  42. }while (leg!=0);
  43. }
  44. float SuelMax(float v[], int ce){
  45.     float max;
  46. for (int i=0; i<ce; i++){
  47.     if (i==0 || v[i]>max){
  48.         max=v[i];
  49.     }
  50. }
  51.     return max;
  52. }
  53. void MostrarIgualQue(float v[], int ce, float max){
  54.     if (max==0){
  55.         printf ("No hay ningun salario\n");
  56.     }else{
  57. printf ("Numero de legajo de los empleados con mayor salario: ");
  58. for (int i=0; i<ce; i++){
  59.     if (v[i]==max){
  60.         printf ("%d ", i+1);
  61.     }
  62. }}
  63. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement