Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <string.h>
- struct empleado{
- char legajo[5];
- char empleado[35];
- int antiguedad;
- int categoria;
- };
- struct sueldo{
- int antiguedad;
- float porcentaje;
- };
- float sueldo_basico;
- struct empleado *cargaemp(int *);
- struct empleado busca (struct empleado *, int, char legajo[]);
- void calcula(struct empleado *,char empleado[], float *sueldo_retenciones);
- void main(){
- int limite;
- char legajo_aux[5];
- struct empleado *emp, buffer;
- printf("Ingrese el sueldo básico: \n");
- scanf("%f", &sueldo_basico);
- limite = 5;
- emp = cargaemp(&limite);
- printf("Ingrese legajo: \n");
- scanf("%s",legajo_aux);
- buffer = busca(emp,5,legajo_aux);
- if(strcmp(buffer.legajo,"*****") == 0){
- printf("EL EMPLEADO NO EXISTE");
- } else {
- printf("El sueldo con las retenciones incluidas es: \n");
- printf("%f",calcula(buffer));
- }
- }
- struct empleado *cargaemp(int *limite){
- static struct empleado buffer[5];
- int i;
- for(i=0;i<(*limite);i++){
- printf("Ingrese legajo: \n");
- scanf("%s",buffer[i].legajo);
- printf("Ingrese empleado: \n");
- scanf("%s",buffer[i].empleado);
- printf("Ingrese antigüedad: \n");
- scanf("%d",&buffer[i].antiguedad);
- printf("Ingrese categoría: \n");
- scanf("%d",&buffer[i].categoria);
- printf("\n\t\t****\t\t\n\n\n");
- }
- return buffer;
- }
- struct empleado busca(struct empleado *lista, int limite,char legajo[5]){
- static struct empleado buffer;
- int encontrado, i;
- encontrado = 0;
- for(i=0;i<limite;i++){
- if(strcmp(lista[i].legajo,legajo) == 0){
- encontrado = 1;
- strcpy(buffer.empleado,lista[i].empleado);
- strcpy(buffer.legajo,lista[i].legajo);
- buffer.antiguedad = lista[i].antiguedad;
- buffer.categoria = lista[i].categoria;
- }
- }
- if(encontrado == 0){
- strcpy(buffer.legajo,"*****");
- }
- return buffer;
- }
Advertisement
Add Comment
Please, Sign In to add comment