SHARE
TWEET

Untitled

a guest Sep 18th, 2019 92 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include<bits/stdc++.h>
  2.  
  3. using namespace std;
  4.  
  5. int main() {
  6.     string input;
  7.     int multiple, degree;
  8.  
  9.     cin >> input;
  10.  
  11.     while(input[0] != '0') {
  12.         degree = 0;
  13.         cout << input;
  14.  
  15.         do {
  16.             multiple = 0;
  17.             for(int i = 0; i < input.length(); ++i) {
  18.                 multiple += (input[i] - '0');
  19.             }
  20.             stringstream switching;
  21.             switching << multiple;
  22.             input = switching.str();
  23.             ++degree;
  24.         } while(input.length() > 1);
  25.  
  26.         if(input[0] == '9') {
  27.             cout << " is a multiple of 9 and has 9-degree " << degree << "."<< endl;
  28.         } else {
  29.             cout << " is not a multiple of 9." << endl;
  30.         }
  31.  
  32.         cin >> input;
  33.  
  34.     }
  35. }
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