Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- using namespace std;
- int main(){
- int n , t = 0;
- cout << "please enter the even number:" << endl; // cout string
- while( cin >> n && n&1 ) cout << "error!please enter the even number:" << endl; //not even number
- while( !(n&1) ) {
- n /= 2;
- ++t;
- }
- cout << "the odd number is: " << n << endl; // caculate and cout result
- cout << "total times is: " << t << endl; // caculate and cout result
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement