Quirinus

LinearSearch_3

Oct 19th, 2018
576
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.47 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main()
  5. {
  6.     int polje[8] = { 5, 3, 5, 4, 8, 8, 2, 1 };
  7.     int trazimo = 8;
  8.     int brojac = 0;
  9.  
  10.     for (int i = 0; i < 8; i++)
  11.     {
  12.         if (polje[i] == trazimo)
  13.         {
  14.            brojac++;
  15.         }
  16.     }
  17.  
  18.     if (brojac % 2 == 0)
  19.     {
  20.        cout << "Broj " << trazimo << " se pojavljuje paran broj puta." << endl;
  21.     }
  22.     else
  23.     {
  24.         cout << "Broj " << trazimo << " se pojavljuje neparan broj puta." << endl;
  25.     }
  26.  
  27.     system("PAUSE");
  28.     return 0;
  29. }
Advertisement
Add Comment
Please, Sign In to add comment