Ledger Nano X - The secure hardware wallet
SHARE
TWEET

Untitled

a guest Mar 28th, 2020 67 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. typedef struct
  2. {
  3.     char *name;
  4.     int starting_time;
  5.     int remaining_time;
  6. }Process;
  7.  
  8. typedef struct
  9. {
  10.     Process data;
  11.     struct Node *next;
  12. } Node;
  13.  
  14. Node* newNode(Process val)
  15. {
  16.     Node* n=malloc(sizeof(Node));
  17.     n->data=val;
  18.     n->next=NULL;
  19.     return n;
  20. }
  21.  
  22. typedef struct
  23. {
  24.     Node *front,*rear;
  25. } Queue;
  26.  
  27. Queue *initQueue()
  28. {
  29.     Queue *q=malloc(sizeof (Queue));
  30.     q->front=q->rear=NULL;
  31.     return q;
  32. }
  33.  
  34. /*Queue*newQueue()
  35. {
  36.     Queue*q=malloc(sizeof(Queue));
  37.     q->front=NULL;
  38.     q->rear=NULL;
  39.     return 1;
  40. }*/
  41. int isEmpty(Queue *q)
  42. {
  43.     if(q->front==NULL)
  44.         return 1;
  45.     return 0;
  46. }
  47. void enqueue(Queue *q,Process val)
  48. {
  49.     Node *ptr = newNode(val);
  50.     if (q->front==NULL)
  51.         q->front=q->rear=ptr;
  52.     else
  53.     {
  54.         q->rear->next=ptr;
  55.         q->rear=ptr;
  56.     }
  57. }
  58. Process dequeue (Queue *q)
  59. {
  60.     Process num;
  61.     if (q->front==NULL)
  62.         return num;
  63.     else
  64.     {
  65.         num=q->front->data;
  66.         q->front=q->front->next;
  67.         return num;
  68.     }
  69. }
  70. void printQueue(Queue *q)
  71. {
  72.    Node*temp=q->front;
  73.    while (temp!=NULL)
  74.    {
  75.        printf("%d",temp->data);
  76.        temp=temp->next;
  77.    }
  78. }
  79.  
  80. void RoundRobin (char* filename){
  81.     Process p[100];
  82.     FILE *f=fopen(filename,"r");
  83.    
  84.     if(f!=NULL)
  85.     {
  86.         printf("in if");
  87.         filename=malloc(260);
  88.         int count =4;
  89.         for(int i=0;i<count;i++)
  90.         {
  91.             p[i].name=malloc(260);
  92.          fscanf(f,"%s %d %d",p[i].name,p[i].starting_time,p[i].remaining_time);
  93.           printf("%s\t%d\t%d\n",p[i].name,p[i].starting_time,p[i].remaining_time);
  94.         }
  95.         fclose(f);
  96.     }
  97. else{printf("file not found\n");}
  98.  
  99. }
  100.  
  101. int main()
  102. {
  103.     printf("enter file name\n");
  104.     char *filename;
  105.     filename=malloc(260);
  106.     fgets(filename,260,stdin);
  107.     RoundRobin(filename);
  108.     return 0;
  109. }
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