Guest User

Untitled

a guest
Dec 2nd, 2019
114
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