SHARE
TWEET

Untitled

a guest Dec 2nd, 2019 92 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <iostream>
  2.  
  3. bool boolIsHappy (int n) {
  4.     while (n > 9) {
  5.         if (n%10 <(n/10) % 10) {
  6.             return false;
  7.         }
  8.         n = n / 10;
  9.     }
  10.     if (n % 10 >= (n/10) % 10) return true;
  11.     return false;
  12. }
  13.  
  14.  
  15. int main () {
  16.     int k = 0;
  17.     for (int i = 0;i<999999;i++) {
  18.         if (boolIsHappy(i)) k++;
  19.     }
  20.     std::cout << k;
  21. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top