Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <math.h>
- #include <string>
- using namespace std;
- int SUMA_CYFR(int a);
- int main(){
- cout << "wprowadz liczbe: " << endl;
- int a;
- cin >> a;
- int wynik = SUMA_CYFR(a);
- while (wynik >= 10) wynik = SUMA_CYFR(wynik);
- cout << "wynik to: " << wynik << endl;
- }
- int SUMA_CYFR(int a){
- string b = to_string(a);
- int c = 0;
- for (int i = 0; i < b.length(); i++) c += b[i] - '0';
- return c;
- }
Advertisement
Add Comment
Please, Sign In to add comment