Advertisement
Guest User

patient

a guest
Aug 20th, 2019
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.86 KB | None | 0 0
  1. #include <stdlib.h>
  2. #include <stdio.h>
  3. #include <string.h>
  4. #define N 0
  5.  
  6. struct data{
  7.     char name[50];
  8.     char time[50];
  9.     struct data *next;
  10. };
  11.  
  12. typedef data node;
  13. node *head=N,*last=N;
  14.  
  15. void addpatient(char na[50],char ti[50]){
  16.     node *temp=(node *)malloc(sizeof(node));
  17.     strcpy(temp->name,na);
  18.     strcpy(temp->time,ti);
  19.  
  20.     if(head==N){
  21.         head=temp;
  22.         last=temp;
  23.         return;
  24.     }
  25.     last->next=temp;
  26.     last=temp;
  27. }
  28. void create(){
  29.     int n;
  30.     scanf("%d",&n);
  31.     int p=0;
  32.     while(p<n){
  33.         char na[50];
  34.         char ti[50];
  35.         scanf("%s",&na);
  36.         scanf("%s",&ti);
  37.  
  38.         addpatient(na,ti);
  39.         ++p;
  40.     }
  41.  
  42. }
  43. void print(){
  44.     node *temp= head;
  45.     int i;
  46.    
  47.     while(1){
  48.         printf("%s,%s",temp->name,temp->time);
  49.         scanf("%d",&i);
  50.         if(i==1)
  51.           create();
  52.          if(temp->next==N)
  53.             break;
  54.         else
  55.             temp=temp->next;   
  56.     }
  57. }
  58.  
  59. int main(){
  60.     create();
  61.     print();
  62.     return 0;
  63. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement