/* PROGRAMA QUE TRABAJA CON ESTRUCTURAS PARA ALMACENAR SU INFORMACION*/
// para compilar: gcc p002.c -o e002.out
#include <stdio.h>
#include<string.h>
#define ntra 3
#define nhor 12
#define ndias 6
struct trabajador{
int horario[nhor][ndias],vhora,edad,nhtra;
char nom[12],ape[12],sexo;
long int ced,tel;
};
int main (){
int i,j,k,icon,prod=1;
char t1[20],t2[70];
struct trabajador emp[ntra];
FILE *fdat;
fdat=fopen("plantilla.txt","r");
for(k=0;k<ntra;k++){
fscanf(fdat,"%s %s %s %s %s %ld",t1,emp[k].nom,t1,emp[k].ape,t1,&emp[k].ced);
fscanf(fdat,"%s %s %d %s %d %s %c %s %ld",t1,t1,&emp[k].vhora,t1,&emp[k].edad,t1,&emp[k].sexo,t1,&emp[k].tel);
for(i=0;i<10;i++)fscanf(fdat,"%s",t1);
icon=0;
for(i=0;i<nhor;i++){
fscanf(fdat,"%s",t1);
for(j=0;j<ndias;j++){
fscanf(fdat,"%d",&emp[k].horario[i][j]);
if(emp[k].horario[i][j]==1)icon++;
}
}
emp[k].nhtra=icon;
fscanf(fdat,"%s",t2);
}
fclose(fdat);
char disem[6][11]={"lunes","martes","miercoles","jueves","viernes","sabado"};
char hora[12][6]={"06a07","07a08","08a09","09a10","10a11","11a12","12a13","13a14", "14a15","15a16","16a17","17a18"};
// investigar cuando todos los empleasdos estan trabajando
printf("\n *** DIAS Y HORAS EN QUE TODOS LOS TRABAJADORES SE ENCUENTRAN LABORANDO***\n\n");
for(j=0;j<ndias;j++)for(i=0;i<nhor;i++){
prod=1;
for(k=0;k<ntra;k++)prod*=emp[k].horario[i][j];
if(prod==1)printf(" el dia %s en el horario de %s \n",disem[j],hora[i]);
}
return 0;
}
Suscribirse a:
Enviar comentarios (Atom)
No hay comentarios:
Publicar un comentario