Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <locale.h>
- #include <time.h>
- #include <iostream>
- using namespace std;
- int main()
- {
- const int N = 100;
- const int n = 100;
- int count = 0;
- int k = 0;
- int mas1[N], mas2[N];
- int mas3[n];
- int i;
- setlocale(LC_ALL, "Russian");
- printf("Датчик случайных чисел задаст два массива, записанные в столбик:\n");
- srand(time(0));
- for(i=0;i<N;i++)
- {
- mas1[i] = rand() % 90;
- mas2[i] = rand() % 90;
- printf("%d %d", mas1[i], mas2[i]);
- printf("\n");
- }
- printf("=====================================\n");
- printf("Создан третий массив, записанный в строчку, из индексов посторяющихся чисел\n");
- for(i=0;i<N-1;i++)
- if(mas1[i] == mas2[i+1])
- {
- mas3[k] = i;
- k++;
- count++;
- }
- for(i=0;i<count;i++)
- {
- cout << mas3[i] << " ";
- }
- printf("\n");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement