Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <iomanip>
- using namespace std;
- int const n = 10;
- int a[n], b[n], c[n];
- int q = 0; // кол-во пересечений
- int main() {
- setlocale(LC_ALL, "Rus");
- for (int i = 0; i < n; i++) {
- a[i] = rand() % 10;
- cout << setw(4) << a[i];
- }
- cout << '\n';
- for (int i = 0; i < n; i++) {
- b[i] = rand() % 10;
- cout << setw(4) << b[i];
- }
- cout << '\n';
- for (int i = 0; i < n; i++) {
- for (int j = 0; j < n; j++) {
- if (a[i] == b[j]) {
- cout << a[i] << ' ' << b[j] << '\n';
- c[i] = a[i];
- }
- }
- }
- //* самое интересное, Некит, не проеби
- for (int i = 0; i < n; i++) {
- if (c[i] != 0) {
- q++;
- }
- cout << setw(4) << c[i];
- }
- cout << '\n' << "Число совпадений " << q << '\n';
- int* prt_q = new int[q];
- for (int i = 0; i < n; i++) {
- for (int j = 0; j < 1; j++) {
- if (c[i] != 0) {
- prt_q[j] = c[i];
- cout << setw(4) << prt_q[j];
- }
- }
- }
- delete[] prt_q;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement