Proszę o pomoc, program musi działać w C++.
# include <iostream>using namespace std;main(){ int t,n,x,rewersy = 0; cin>>t; n = t; while (t--) { cin>>x; if ( x == 1 ) rewersy += 1;} if ( rewersy > n - rewersy) cout<<n - rewersy; else cout<<rewersy; }
" Life is not a problem to be solved but a reality to be experienced! "
© Copyright 2013 - 2024 KUDO.TIPS - All rights reserved.
# include <iostream>
using namespace std;
main()
{
int t,n,x,rewersy = 0;
cin>>t;
n = t;
while (t--)
{
cin>>x; if ( x == 1 ) rewersy += 1;
}
if ( rewersy > n - rewersy)
cout<<n - rewersy;
else
cout<<rewersy;
}