Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int main()
- {
- char caz;
- cout << "Introdu cazul:"; cin >> caz;
- switch (caz)
- {
- case 'i':
- {
- int n, m, a[100], b[100], c[200];
- cout << "n="; cin >> n;
- cout << "m="; cin >> m;
- for (int i = 0; i < n; ++i)
- cin >> a[i];
- cout << "===============";
- cout << endl;
- for (int i = 0; i < m; i++)
- cin >> b[i];
- int i = 0, j = 0, k = 0;
- while (i < n && j < m)
- {
- if (a[i] > b[j])
- {
- c[k] = b[j];
- j++;
- k++;
- }
- else
- {
- c[k] = a[i];
- i++;
- k++;
- }
- }
- if (i <= n)
- {
- for (int x = i; x < n; x++)
- {
- c[k] = a[x];
- k++;
- }
- }
- if (j <= m)
- {
- for (int y = j; y < m; y++)
- {
- c[k] = b[y];
- k++;
- }
- }
- for (int i = 0; i <k; i++)
- cout << c[i] << " ";
- break;
- }
- }
- system("pause");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement