crsandu

Untitled

Jan 3rd, 2016
243
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.38 KB | None | 0 0
  1. Problema: http://www.pbinfo.ro/?pagina=probleme&id=633
  2.  
  3. #include <iostream>
  4. using namespace std;
  5.  
  6. int v[1005] , n , nri , nrp;
  7.  
  8. int main()
  9. {
  10. cin >> n;
  11. for(int i = 1 ; i <= n ; ++i)
  12. cin >> v[i];
  13. nri = nrp = 0;
  14. for(int i = 1 ; i <= n ; ++i)
  15. if(v[i] % 2 == 0)
  16. nrp ++;
  17. else
  18. nri ++;
  19. if(nrp > nri)
  20. cout << nrp - nri;
  21. else
  22. cout << nri - nrp;
  23. return 0;
  24. }
Advertisement
Add Comment
Please, Sign In to add comment