Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <set>
- const int S = 4;
- using namespace std;
- int main() {
- setlocale(LC_ALL, "rus");
- int a[S] = {}, b[S] = {}, c[S] = {};
- int it = 0;
- cout << "Введите " << S << " чисел для первого массива" << endl;
- for (int i = 0; i < S; i++)
- {
- cout << "a[" << i << "]=";
- cin >> a[i];
- }
- cout << endl;
- cout << "Введите " << S << " чисел для второго массива" << endl;
- for (int i = 0; i < S; i++)
- {
- cout << "b[" << i << "]=";
- cin >> b[i];
- }
- cout << endl;
- set<int> cs;
- for (int i = 0; i < S; ++i) {
- int num = 0; // Счётчик
- bool check = false; // Проверка
- for (int j = 0; j < S; ++j) {
- if (a[i] == b[j])
- break;
- if (a[i] != b[j]) {
- ++num;
- if (num == S)
- check = true;
- if (check)
- cs.insert(a[i]);
- }
- }
- }
- if (cs.empty()) {
- cout << "Массивы индентичные.";
- return 0;
- }
- cout << "Третий массив равен: " << endl;
- for (auto s : cs) {
- cout << s << " ";
- c[it] = s;
- ++it;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement