Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
- //Alan Cordeiro
- //Listas encadeadas
- struct eficiencia {
- int segundos;
- struct eficiencia *prox;
- };
- void imprime (struct eficiencia *cabeca){
- printf("Segundos gastos por operarios\n");
- struct eficiencia *aux;
- aux = cabeca;
- while(aux->prox != NULL) {
- aux = aux->prox;
- printf("%d\n",aux->segundos);
- }
- }
- void addOperario(struct eficiencia *cabeca) {
- struct eficiencia *novo;
- int segundos;
- novo = (struct eficiencia *) malloc(sizeof(cabeca));
- printf("Insira o tempo gasto pelo operario\n");
- scanf("%d",&segundos);
- novo->segundos = segundos;
- novo->prox = cabeca->prox;
- cabeca->prox = novo;
- }
- int main () {
- int operarios;
- printf("Insira a quantidade de operarios\n");
- scanf("%d",&operarios);
- struct eficiencia grupo;
- grupo.prox = NULL;
- for(int x=0; x < operarios; x++)
- addOperario(&grupo);
- imprime(&grupo);
- system("pause");
- }
Add Comment
Please, Sign In to add comment