Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <ctime>
- using std::cin;
- using std::cout;
- using std::endl;
- #define TAB '\t';
- #define E2 cout << "\n\n";
- #define E4 cout << "\n\n\n\n";
- #define E10 cout << "\n\n\n\n\n\n\n\n\n\n";
- void main()
- {
- setlocale(LC_ALL, "Ru");
- srand(time(NULL));
- const int size = 20;
- int Arona[size];
- int Borea[size];
- int Memories[size];
- int nmbr, tms, pstn;
- cout << "Arona:" << TAB;
- for (int i = 0; i < size; ++i)
- cout << (Arona[i] = rand() % 10) << TAB;
- E2
- cout << "Borea:" << TAB;
- for (int i = 0; i < size; ++i)
- cout << (Borea[i] = rand() % 10) << TAB;
- E4
- for (int i = 0; i < size; ++i)
- {
- tms = 1;
- for (int j = 0; j < size; ++j)
- Memories[j] = -1;
- for (int j = i + 1, l = 0; j < size; ++j, ++l)
- {
- if (Arona[i] == Borea[j])
- {
- nmbr = Arona[i];
- tms += 1;
- pstn = j;
- Memories[l] = pstn;
- }
- }
- for (int j = i - 1; j >= 0; --j)
- {
- if (nmbr == Borea[j]) tms = 1;
- if (nmbr == Arona[i]) tms = 1;
- }
- if (tms > 1)
- {
- cout << endl << "Количество встреч числа " << nmbr << " массива Arona в массиве Borea равно " << tms - 1<< endl;
- cout << "Данное число имеет индекс " << i << " в массиве Arona";
- cout << " и имеет индексы ";
- for (int k = 0; k < size; ++k)
- {
- if (Memories[k] >= 0)
- cout << Memories[k] << " ";
- }
- cout << " в массиве Borea" << endl;
- }
- }
- E10
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement