Aleksandr_Grigoryev

ДЗ №8(существование уникального элемента)

Feb 18th, 2018
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.45 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3. int main()
  4. {
  5.     const int n = 5;
  6.     int a[n] = {1,1,2,2,4};    
  7.     int kol_vo = 0;
  8.     int i, j;
  9.     for (i = 0; i < n; i++)
  10.     {
  11.         bool b = false;
  12.         for (j = i + 1; j < n && a[i] != -9999; j++)
  13.         {
  14.             if ((i!=j) && a[i] ==a[j])
  15.             {
  16.                 b = true;
  17.                 a[j] = -9999;
  18.                
  19.             }
  20.         }
  21.         if (!b && a[i] !=-9999)
  22.             kol_vo++;
  23.     }
  24.     cout << "kol-vo unique simbols numbers= " << kol_vo;
  25.     system("pause");
  26.     return 0;
  27. }
Advertisement
Add Comment
Please, Sign In to add comment