Advertisement
Guest User

Untitled

a guest
Apr 1st, 2020
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.27 KB | None | 0 0
  1. #include<iostream>
  2.  
  3. #include<bits/stdc++.h>
  4.  
  5. using namespace std;
  6.  
  7. struct c {
  8.  
  9. int a;
  10.  
  11. struct c *k;
  12. };
  13. struct c *s=0;
  14.  
  15. struct c *p= 0;
  16.  
  17. void come(int x){
  18.  
  19. struct c *m;
  20.  
  21. m = (c*) malloc (sizeof(c));
  22.  
  23. m->a=x;
  24.  
  25. m->k=0;
  26.  
  27. if(s==0 && p==0){s=p=m;}
  28.  
  29. else{p->k=m;p=m;}
  30. }
  31. void show ()
  32. {
  33. struct c *t;
  34.  
  35. if(s==0 && p==0){cout << "Line Empty" << endl;}
  36. else{t=s;while (t!=0){ cout << endl << " " << t->a << endl;
  37. t=t->k;
  38. }
  39. }
  40. }
  41.  
  42. void out (int y){
  43. struct c *o;
  44. o=s;
  45. if(s == 0 && p==0)
  46. {
  47. cout << "Empty Line" << endl;
  48. }
  49. else{
  50. s=s->k;
  51. free(o);
  52. }
  53. }
  54.  
  55. int main()
  56.  
  57. {
  58. cout << " Make a safe distance bewtten each other" << endl;
  59. int i,n,j;
  60. cout << endl << " Total number of people today : ";
  61. cin >> j;
  62. for(i=1;i<=j;i++){come(i);}
  63. show();
  64. out(1);
  65. show();
  66. out(2);
  67. show();
  68. out(3);
  69. show();
  70. out(4);
  71. show();
  72. out(5);
  73. show();
  74. out(6);
  75. show();
  76. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement