Advertisement
LabiinfaCibGyti

zadanie

Dec 15th, 2019
134
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.77 KB | None | 0 0
  1. #include "stdafx.h"
  2. #include <iostream>
  3. #include <math.h>
  4. using namespace std;
  5. int _tmain(int argc, _TCHAR* argv[])
  6. {
  7.     int i, k=0, n, p=0, r=1;
  8.     double a[50];
  9.     setlocale (0, "rus");
  10.     cout<<"Введите кол-во элементов массива"<<endl;
  11.     cin>>n;
  12.     cout<<"Введите элементы массива"<<endl;
  13.     for (i=0; i<n; i++)
  14.     {
  15.         cin>>a[i];
  16.     }
  17.     cout<<"Массив AVec"<<endl;
  18.     for (i=0; i<n; i++)
  19.     {
  20.         cout<<"AVec["<<i+1<<"]= "<<a[i]<<endl;
  21.     }
  22.     cout<<endl;
  23.     i=1;
  24.     while (k<n)
  25.     {
  26.             if (a[k]==a[i])
  27.             {
  28.                 p++;
  29.                 a[i]=-300000-r;
  30.                 r++;
  31.             }
  32.             if (i+1==n)
  33.             {
  34.                 if (p!=0)
  35.                 {
  36.                     cout<<a[k]<<endl;
  37.                 }
  38.                 k++;
  39.                 p=0;
  40.                 if (k+1<n)
  41.                     i=k+1;
  42.                 else k=n;
  43.             }
  44.             else i++;
  45.     }
  46.     return 0;
  47. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement