Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<bits/stdc++.h>
- using namespace std;
- int main() {
- string input;
- int multiple, degree;
- cin >> input;
- while(input[0] != '0') {
- degree = 0;
- cout << input;
- do {
- multiple = 0;
- for(int i = 0; i < input.length(); ++i) {
- multiple += (input[i] - '0');
- }
- stringstream switching;
- switching << multiple;
- input = switching.str();
- ++degree;
- } while(input.length() > 1);
- if(input[0] == '9') {
- cout << " is a multiple of 9 and has 9-degree " << degree << "."<< endl;
- } else {
- cout << " is not a multiple of 9." << endl;
- }
- cin >> input;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement