Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int main(){
- int n, y, x;
- y = 0;
- cin >> n; // n = 4
- /*
- Singura diferenta este la FOR
- Nu am mai folosit while (n > 0)
- */
- for(int i = n; n > 0; i--){
- cout << "Introdu x: ";
- cin >> x;
- while(x % 2 == 0)
- x = x / 2;
- if(x == 1)
- y = y + 1;
- }
- cout << "Y = " << y;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment