Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #define Nmax 10001
- using namespace std;
- struct Coada
- {
- int q[Nmax];
- int pr, ul;
- void Init()
- {
- pr = 0;
- ul = - 1;
- }
- int Empty()
- {
- if(pr <= ul) return 0;
- return 1;
- }
- void Push(int x)
- {
- ul++;
- q[ul] = x;
- }
- void Pop()
- {
- if(!Empty()) pr++;
- }
- int Front()
- {
- return q[pr];
- }
- int Size()
- {
- return ul - pr + 1;
- }
- };
- int main()
- {
- ///--Initializari si alte chestii--
- int i;
- int a2[] = {5, 3, 9, 1, 4, 7, 1}, n = 7;
- int b2[] = {9, 1, 4, 2, 4, 10, 0, 6, 3, 7}, m = 10;
- Coada a, b;
- a.Init(); b.Init();
- for(i = 0; i < n; i++)
- a.Push(a2[i]);
- for(i = 0; i < m; i++)
- b.Push(b2[i]);
- ///--Programu--
- for(i = 0; i < n; i++) /// while(!a.Empty())
- {
- b.Push(a.Front());
- a.Pop();
- }
- for(i = 0; i < m; i++)
- {
- a.Push(b.Front());
- b.Pop();
- }
- ///--Afisari--
- cout << "a: ";
- while(!a.Empty())
- {
- cout << a.Front() << " "; a.Pop();
- }
- cout << "\nb: ";
- while(!b.Empty())
- {
- cout << b.Front() << " "; b.Pop();
- }
- cout << "\n";
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement