Advertisement
MeehoweCK

Untitled

Oct 26th, 2020
2,054
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.48 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int miniecia(bool* tab, int n)
  6. {
  7.     int wynik = 0;
  8.  
  9.     for(int i = 0; i < (n-1); ++i)
  10.     {
  11.         if(tab[i] == 1)
  12.             continue;
  13.         for(int j = i + 1; j < n; ++j)
  14.             if(tab[j] == 1)
  15.                 ++wynik;
  16.     }
  17.     return wynik;
  18. }
  19.  
  20. int main()
  21. {
  22.     int n;
  23.     cin >> n;
  24.     bool auta[n];
  25.     for(int i = 0; i < n; ++i)
  26.         cin >> auta[i];
  27.  
  28.     cout << miniecia(auta, n);
  29.     return 0;
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement