Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*programa que simula uma biqueira */
- #include <stdio.h> /*I/O*/
- #include <stdlib.h>/*malloc */
- #include <stdbool.h>/*bool*/
- #include <time.h>/*srand && rand */
- #include <unistd.h> /*sleep */
- typedef struct Queue
- {
- int qtd_po,qtd_mac,qtd_crack,xlen,len,size;
- struct Queue *begin,*end;
- }queue;
- queue *queue_create(void)
- {
- queue *q = (queue *) malloc(sizeof(queue));
- if (q!= NULL)
- q->begin =NULL;
- q->end = NULL;
- return q;
- }
- typedef struct
- {
- int Hh,Mm,hours,Minutes,secunds,dd;
- }t;
- #define MINUTES 3
- int len=0,size=0,_size1=0,lucro=0,lucro1=0,lucro2=0;
- int random_id(void)
- {
- srand(time(NULL));
- return rand() %1000;
- }
- queue *enfileirar(queue **q,int qtd,int qtd1,int qtd2)
- {
- queue *novo = (queue *) malloc(sizeof(queue));
- int y,r,x,k,horas,minutos;
- printf("\nINFORME A HORA ATUAL: \n");
- printf("HH/MM \n > "); scanf("%d %d",&horas,&minutos);
- printf("")
- t *clock_t = (t *) malloc(sizeof(t));
- clock_t->Hh = horas;
- clock_t->Mm = minutos;
- while(1){
- for(clock_t->secunds=0; clock_t->secunds <=MINUTES; clock_t->secunds++){
- sleep(0x1);
- printf("\nSAO EXATAMENTE: { %d : %d : %d } \n",clock_t->Hh,clock_t->Mm,clock_t->secunds);
- if (clock_t->secunds == MINUTES)
- {
- clock_t->Mm = clock_t->Mm+1;
- if (clock_t->Mm >= 59){
- clock_t->Hh = clock_t->Hh+1;
- clock_t->Mm = 0;
- }if (clock_t->Hh == 59)
- clock_t->Hh = clock_t->Hh+1;
- if (clock_t->Hh >= 23)
- clock_t->Hh = clock_t->Hh =0;
- }
- }
- }
- return novo;
- }
- void show(queue **q)
- {
- printf("\n\t---------------------------");
- printf("\n\t|MACONHA | COCAINA | CRACK |");
- printf("\n\t|--------|---------|-------|");
- printf("\n\t|QUANTIDADE| QUANTIDADE | QUANTIDADE |");
- printf("\n\t| %d | %d | %d |",len,size,_size1);
- printf("\n\t| LUCROS | LUCROS | LUCROS |");
- printf("\n\t|----------------------------");
- printf("\n\t| M: %d$| CO: %d$ | CK:%d$ |",lucro,lucro1,lucro2);
- printf("\n\t|----------------------------|");
- }
- int main()
- {
- queue *q = queue_create();
- int opc,po,mac,cra;
- if (q != NULL)
- for(;;){
- printf("\n\t_(0)--------- [ SAIR ]");
- printf("\n\t_(1)--------- [ Enfileirar ] ");
- printf("\n\t_(2)--------- [ TABELA DE LUCROS ] \n");
- printf("> "); scanf("%d",&opc);
- switch(opc){
- case 0:
- exit( 0 );
- case 1:
- printf("\nDIGITE A quantidade dos produtos a ser inseridos \n");
- printf("PO: "); scanf("%d",&po);
- printf("\n\tMACONHA: "); scanf("%d",&mac);
- printf("\n\tCRACK: "); scanf("%d",&cra);
- q=enfileirar(&q,po,mac,cra);
- break;
- default:
- break;
- case 2:
- show(&q);
- break;
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement