milardovich

Final 8 - Sintaxis

Apr 27th, 2013
167
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.82 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <string.h>
  3.  
  4. struct empleado{
  5.     char legajo[5];
  6.     char empleado[35];
  7.     int antiguedad;
  8.     int categoria;
  9. };
  10.  
  11. struct sueldo{
  12.     int antiguedad;
  13.     float porcentaje;
  14. };
  15.  
  16. float sueldo_basico;
  17.  
  18. struct empleado *cargaemp(int *);
  19.  
  20. struct empleado busca (struct empleado *, int, char legajo[]);
  21.  
  22. void calcula(struct empleado *,char empleado[], float *sueldo_retenciones);
  23.  
  24. void main(){
  25.     int limite;
  26.     char legajo_aux[5];
  27.     struct empleado *emp, buffer;
  28.     printf("Ingrese el sueldo básico: \n");
  29.     scanf("%f", &sueldo_basico);
  30.     limite = 5;
  31.     emp = cargaemp(&limite);
  32.  
  33.     printf("Ingrese legajo: \n");
  34.     scanf("%s",legajo_aux);
  35.     buffer = busca(emp,5,legajo_aux);
  36.  
  37.     if(strcmp(buffer.legajo,"*****") == 0){
  38.         printf("EL EMPLEADO NO EXISTE");
  39.     } else {
  40.         printf("El sueldo con las retenciones incluidas es: \n");
  41.         printf("%f",calcula(buffer));
  42.     }
  43. }
  44.  
  45. struct empleado *cargaemp(int *limite){
  46.     static struct empleado buffer[5];
  47.     int i;
  48.     for(i=0;i<(*limite);i++){
  49.         printf("Ingrese legajo: \n");
  50.         scanf("%s",buffer[i].legajo);
  51.         printf("Ingrese empleado: \n");
  52.         scanf("%s",buffer[i].empleado);
  53.         printf("Ingrese antigüedad: \n");
  54.         scanf("%d",&buffer[i].antiguedad);
  55.         printf("Ingrese categoría: \n");
  56.         scanf("%d",&buffer[i].categoria);
  57.         printf("\n\t\t****\t\t\n\n\n");
  58.     }
  59.  
  60.     return buffer;
  61. }
  62.  
  63. struct empleado busca(struct empleado *lista, int limite,char legajo[5]){
  64.     static struct empleado buffer;
  65.     int encontrado, i;
  66.     encontrado = 0;
  67.     for(i=0;i<limite;i++){
  68.         if(strcmp(lista[i].legajo,legajo) == 0){
  69.             encontrado = 1;
  70.             strcpy(buffer.empleado,lista[i].empleado);
  71.             strcpy(buffer.legajo,lista[i].legajo);
  72.             buffer.antiguedad = lista[i].antiguedad;
  73.             buffer.categoria = lista[i].categoria;
  74.         }
  75.     }
  76.  
  77.     if(encontrado == 0){
  78.         strcpy(buffer.legajo,"*****");
  79.     }
  80.     return buffer;
  81. }
Advertisement
Add Comment
Please, Sign In to add comment