Advertisement
Guest User

Untitled

a guest
May 25th, 2016
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.08 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <locale.h>
  4. #include <time.h>
  5. #include <iostream>
  6. using namespace std;
  7. int main()
  8. {
  9.     const int N = 100;
  10.     const int n = 100;
  11.     int count = 0;
  12.     int k = 0;
  13.     int mas1[N], mas2[N];
  14.     int mas3[n];
  15.     int i;
  16.     setlocale(LC_ALL, "Russian");
  17.     printf("Датчик случайных чисел задаст два массива, записанные в столбик:\n");
  18.     srand(time(0));
  19.     for(i=0;i<N;i++)
  20.     {
  21.         mas1[i] = rand() % 90;
  22.         mas2[i] = rand() % 90;
  23.         printf("%d %d", mas1[i], mas2[i]);
  24.         printf("\n");
  25.     }
  26.     printf("=====================================\n");
  27.     printf("Создан третий массив, записанный в строчку, из индексов посторяющихся чисел\n");
  28.     for(i=0;i<N-1;i++)
  29.         if(mas1[i] == mas2[i+1])
  30.         {
  31.             mas3[k] = i;
  32.             k++;
  33.             count++;
  34.         }
  35.     for(i=0;i<count;i++)
  36.     {
  37.         cout << mas3[i] << " ";
  38.     }
  39.     printf("\n");
  40.     return 0;
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement