Advertisement
Josif_tepe

Untitled

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