Advertisement
dllbridge

Untitled

Oct 27th, 2023
713
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 2.00 KB | None | 0 0
  1.  
  2. /*
  3. #include <stdio.h>
  4.  
  5.  
  6.  
  7. void foo(int n);
  8.  
  9. /////////////////////////////////////////////////////
  10. int main()
  11. {
  12.  
  13.     int n = 100;
  14.    
  15.     foo(n);
  16.  
  17.     printf("n from matn = %d\n", n);
  18. }
  19.  
  20.  
  21. //////////////////////////////////////////////////////
  22. void foo(int n)
  23. {
  24.    
  25.      n = n - 77;
  26. }
  27.  
  28.  
  29.  
  30.  
  31. */
  32.  
  33.  
  34.  
  35.  
  36.  
  37.  
  38.  
  39.  
  40.  
  41.  
  42.  
  43.  
  44.  
  45.  
  46. /*
  47. #include <iostream>
  48. #include    <queue>
  49.  
  50. using namespace std;
  51.  
  52.  
  53. //////////////////////////////////////////////////////////////////////
  54. int main()
  55. {
  56.  
  57.  
  58.   queue<string> animals;                             // create a queue of string
  59.  
  60.  
  61.   animals.push("Cat");                           // push elements into the queue
  62.   animals.push("Dog");
  63.  
  64.   cout << "Queue: ";
  65.  
  66.  
  67.    
  68.  
  69.  
  70.   while(animals.empty() != 1)   // print elements of queue loop until queue is empty
  71.   {
  72.                                          
  73.     cout << animals.front() << ", ";                         // print the element
  74.  
  75.     animals.pop();                                 // pop element from the queue
  76.  
  77.   }
  78.  
  79.   cout << endl;
  80.  
  81.   return 0;
  82. }
  83. */
  84.  
  85.  
  86.  
  87.  
  88.  
  89.  
  90.  
  91. #include <iostream>
  92. #include    <queue>
  93. using namespace std;
  94.  
  95.  
  96. void display_queue(queue<string> q);               // function prototype for display_queue utility
  97. /////////////////////////////////////////////////////
  98. int main() {
  99.  
  100.  
  101.   queue<string> animals;                           // create a queue of string
  102.  
  103.  
  104.   animals.push("Cat");                             // push element into the queue
  105.   animals.push("Dog");
  106.   animals.push("Fox");
  107.  
  108.   cout << "Initial Queue: ";
  109.   display_queue(animals);
  110.  
  111.  
  112.   animals.pop();                                   // remove element from queue
  113.  
  114.   cout << "Final Queue: ";
  115.   display_queue(animals);
  116.  
  117.   return 0;
  118. }
  119.  
  120.  
  121.  
  122. ///////////////////////////////////////////////// utility function to display queue
  123. void display_queue(queue<string> q)
  124. {
  125.    
  126.    while(q.empty() != 1)
  127.    {
  128.       cout << q.front() << ", ";
  129.       q.pop();
  130.    }
  131.  
  132.   cout << endl;
  133. }
  134.  
  135.  
  136.  
  137.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement