Advertisement
Guest User

Untitled

a guest
Sep 18th, 2019
135
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.76 KB | None | 0 0
  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. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement