Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- void nhapmang(int a[], int m, int b[], int n)
- {
- for (int i = 0; i < m; i++)
- {
- cout << "nhap phan tu thu " << i + 1 << ": ";
- cin >> a[i];
- }
- for (int i = 0; i < n; i++)
- {
- cout << "nhap phan tu thu " << i + 1 << ": ";
- cin >> b[i];
- }
- }
- void xuatmang(int a[], int n)
- {
- for (int i = 0; i < n; i++)
- {
- cout << "phan tu thu " << i + 1 << ": " << a[i] << endl;
- }
- }
- void xoa(int a[], int k, int &n)
- {
- for (int i = k; i < n - 1; i++)
- a[i] = a[i + 1];
- n--;
- }
- void xoagiatrik(int a[], int k, int &n)
- {
- for (int i = 0; i < n; i++)
- {
- if (a[i] == k) xoa(a, i, n);
- }
- }
- void xoatrung(int a[], int &n, int b[], int &m)
- {
- int i, j, k = 0, m1 = m;
- for (i = 0; i < n; i++)
- {
- k = a[i];
- xoagiatrik(b, k, m);
- if (m1 > m)
- {
- xoagiatrik(a, k, n);
- m1 = m;
- i--;
- }
- }
- }
- void main()
- {
- int a[10], b[15], n = 5, m = 7;
- nhapmang(a, n, b, m);
- xoatrung(a, n, b, m);
- cout << "mang 1\n";
- xuatmang(a, n);
- cout << "mang 2\n";
- xuatmang(b, m);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement