SHARE
TWEET

Untitled

a guest Apr 19th, 2019 66 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4. #define L long long
  5.  
  6. typedef struct{
  7.     L *array;
  8.     L head;
  9.     L tail;
  10.     L size;
  11. }Queue;
  12.  
  13.  
  14. void createQueue(Queue *queue, L size){
  15.     queue->array = malloc(sizeof(L) * size);
  16.     queue->head = 0;
  17.     queue->tail = 0;
  18.     queue->size = size;
  19. }
  20.  
  21. void pushQ(Queue *queue, L value){
  22.     printf("%lld\n", 10);
  23.     queue->array[(queue->tail) % queue->size] = value;
  24.     queue->tail++; 
  25. }
  26.  
  27. L popQ(Queue *queue){
  28.     L ans = queue->head;
  29.     queue->head = (queue->head + 1) % queue->size;
  30.     return (queue->head);
  31. }
  32.  
  33. int main(){
  34.     FILE *in = fopen("input.txt", "r");
  35.     FILE *out = fopen("output.txt", "w");
  36.    
  37.     L n_people, n_level;
  38.     fscanf(in, "%lld %lld", &n_people, &n_level);
  39.  
  40.     Queue *people;
  41.  
  42.     createQueue(people, n_people);
  43.     pushQ(people, 10);
  44.     pushQ(people, 20);
  45.     printf("%lld\n", popQ(people));
  46.     printf("%lld\n", popQ(people));
  47.  
  48.     fclose(in);
  49.     fclose(out);
  50.     return 0;
  51. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top