Advertisement
yuawn

Untitled

Oct 6th, 2017
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.45 KB | None | 0 0
  1. #include<iostream>
  2. using namespace std;
  3.  
  4. int main(){
  5.     int n , t = 0;
  6.    
  7.     cout << "please enter the even number:" << endl; // cout string
  8.    
  9.     while( cin >> n && n&1 ) cout << "error!please enter the even number:" << endl; //not even number
  10.    
  11.     while( !(n&1) ) {
  12.         n /= 2;
  13.         ++t;
  14.     }
  15.    
  16.     cout << "the odd number is: " << n << endl; // caculate and cout result
  17.    
  18.     cout << "total times is: " << t << endl; // caculate and cout result
  19.    
  20.     return 0;
  21. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement