int main(void) { int n; printf("Enter the length of the queue: "); scanf("%d", &n); QUEUEinit(n); QUEUEput(1); QUEUEput(2); printf("%d ", QUEUEget()); printf("%d\n", QUEUEget()); return 0; }
int main(void) { int n = 4; QUEUEinit(n); QUEUEput('a'); QUEUEput('b'); QUEUEput('c'); printf("%c\n", QUEUEget()); printf("%c\n", QUEUEget()); printf("%c\n", QUEUEget()); return 0; }
int main(int argc, char *argv[]) { int i, j; int N = atoi(argv[1]); srand(time(NULL)); Q queues[M]; for (i = 0; i < M; ++i) { queues[i] = QUEUEinit(N); } for (i = 0; i < N; ++i) { QUEUEput(queues[rand() % M], i); } for (i = 0; i < M; ++i) { for (j = 0; !QUEUEempty(queues[i]); ++j) { printf("%3d ", QUEUEget(queues[i])); } printf("\n"); } return 0; }
void processa(){ ClienteObj emissor, benificiario; ChequeObj n_cheque; int valor; long refe_aux, refb_aux; n_cheque = QUEUEget(); if(n_cheque != NULL){ valor = n_cheque->valor; refe_aux = n_cheque->refe; refb_aux = n_cheque->refb; emissor = (TREEfind(refe_aux)->item); benificiario = (TREEfind(refb_aux)->item); emissor->valor_total_cheques_emissor -= valor; emissor->num_total_cheques_emissor -= 1; benificiario->valor_total_cheques_benificiario -= valor; benificiario->num_total_cheques_benificiario -= 1; if (((emissor->num_total_cheques_emissor) == 0) && ((emissor->num_total_cheques_benificiario) == 0)) TREEdeletenode(emissor); if (((benificiario->num_total_cheques_emissor) == 0) && ((benificiario->num_total_cheques_benificiario) == 0)) TREEdeletenode(benificiario); } else { printf("Nothing to process\n"); } }
void processa_cheque() { Cliente emp, rec; Cheque a; int valor; long int part, dest; a = QUEUEget(cheques); valor = a -> val; part = a -> part; dest = a -> dest; emp = STsearch(clientes, part); rec = STsearch(clientes, dest); emp -> val_emi -= valor; emp -> num_emi -= 1; rec -> val_rec -= valor; rec -> num_rec -= 1; if (((emp -> num_emi) == 0) && ((emp -> num_rec) == 0)) { STdelete(&clientes, key(emp)); } if (((rec -> num_emi) == 0) && ((rec -> num_rec) == 0)) { STdelete(&clientes, key(rec)); } }
link mergesort(link t) { link u; for (QUEUEinit(N); t != NULL; t = u) { u = t->next; t->next = NULL; QUEUEput(t); } t = QUEUEget(); while (!QUEUEempty()) { QUEUEput(t); t = merge(QUEUEget(), QUEUEget()); } return t; }
void traverse(link h, void (*visit)(link)) { QUEUEinit(max); QUEUEput(h); while (!QUEUEempty()) { (*visit)(h = QUEUEget()); if (h->l != NULL) QUEUEput(h->l); if (h->r != NULL) QUEUEput(h->r); } }
int main(void) { int n = 100, i; QUEUEinit(n-1); for(i = 1; i < n; i++) QUEUEput(i); for (i = 0; i < F; i++) printf("%d\n", QUEUEget()); return 0; }
void traverse(int k) { link t; QUEUEinit(V); QUEUEput(k); while (!QUEUEempty()) if (visited[k = QUEUEget()] == 0) { printf("visit %d\n", k); visited[k] = 1; for (t = adj[k]; t != NULL; t = t->next) if (visited[t->v] == 0) QUEUEput(t->v); } }
int main(int argc, char *argv[]) { int i, j, N = atoi(argv[1]); Q queues[M]; srand(time(NULL)); for (i = 0; i < M; i++) queues[i] = QUEUEinit(N); for (j = 0; j < N; j++) QUEUEput(queues[rand() % M], j); for (i = 0; i < M; i++, printf("\n")) for (j = 0; !QUEUEempty(queues[i]); j++) printf("%3d ", QUEUEget(queues[i])); return 0; }
void DIGRAPHbfsM (Digraph G, Vertex s) { Vertex v, w; cnt = 0; for (v = 0; v < G->V; v++) lbl[v] = -1; QUEUEinit(G->V); lbl[s] = cnt++; QUEUEput(s); while (!QUEUEempty()) { v = QUEUEget(); for (w=0; w < G->V; w++) if (G->Adj[v][w] == 1 && lbl[w] == -1) { lbl[w] = cnt++; QUEUEput(w); } } QUEUEfree(); }
void traverse(int k, void(*visit)(int)) { link t; QUEUEinit(); QUEUEput(k); while (!QUEUEempty()) { k = QUEUEget(); if (visited[k] == 0) { (*visit)(k); visited[k] = 1; for (t = adj[k]; t != NULL; t = t->next) { if (visited[t->v] == 0) { QUEUEput(t->v); } } } } }
void DIGRAPHbfsL (Digraph G, Vertex s) { Vertex v; link p; cnt = 0; for (v = 0; v < G->V; v++) lbl[v] = -1; QUEUEinit(G->V); lbl[s] = cnt++; QUEUEput(s); while (!QUEUEempty()) { v = QUEUEget(); for(p=G->adj[v];p!=NULL;p=p->next) if (lbl[p->w] == -1) { lbl[p->w] = cnt++; QUEUEput(p->w); } } QUEUEfree(); }
int main(void) { int i, t; srand(time(NULL)); QUEUEinit(N); for (i = 0; i < N; ++i) { t = rand() % 100; QUEUEput(t); printf("Putting: %i\n", t); } for (i = 0; i < N; ++i) { t = QUEUEget(); printf("Getting: %i\n", t); } return 0; }
main(int argc, char *argv[]) { int i, j, N = atoi(argv[1]); Q queues[M]; for (i = 0; i < M; i++) { queues[i] = QUEUEinit(N); } for (i = 0; i < N; i++) { QUEUEput(queues[rand() % M], j); } for (i = 0; i < N; i++) { for (j = 0; !QUEUEempty(queues[i]); j++) { printf("%3d", QUEUEget(queues[i])); } } }