Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- #include <stdio.h>
- void foo(int n);
- /////////////////////////////////////////////////////
- int main()
- {
- int n = 100;
- foo(n);
- printf("n from matn = %d\n", n);
- }
- //////////////////////////////////////////////////////
- void foo(int n)
- {
- n = n - 77;
- }
- */
- /*
- #include <iostream>
- #include <queue>
- using namespace std;
- //////////////////////////////////////////////////////////////////////
- int main()
- {
- queue<string> animals; // create a queue of string
- animals.push("Cat"); // push elements into the queue
- animals.push("Dog");
- cout << "Queue: ";
- while(animals.empty() != 1) // print elements of queue loop until queue is empty
- {
- cout << animals.front() << ", "; // print the element
- animals.pop(); // pop element from the queue
- }
- cout << endl;
- return 0;
- }
- */
- #include <iostream>
- #include <queue>
- using namespace std;
- void display_queue(queue<string> q); // function prototype for display_queue utility
- /////////////////////////////////////////////////////
- int main() {
- queue<string> animals; // create a queue of string
- animals.push("Cat"); // push element into the queue
- animals.push("Dog");
- animals.push("Fox");
- cout << "Initial Queue: ";
- display_queue(animals);
- animals.pop(); // remove element from queue
- cout << "Final Queue: ";
- display_queue(animals);
- return 0;
- }
- ///////////////////////////////////////////////// utility function to display queue
- void display_queue(queue<string> q)
- {
- while(q.empty() != 1)
- {
- cout << q.front() << ", ";
- q.pop();
- }
- cout << endl;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement