Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- using namespace std;
- int SUMA_CYFR(int liczba)
- {
- if(liczba==0)
- {
- return 0;
- }
- return (liczba%10)+SUMA_CYFR(liczba/10);
- }
- int main() {
- int liczba;
- cout << "Podaj liczbe: ";
- cin >> liczba;
- do
- {
- liczba = SUMA_CYFR(liczba);
- cout << "Test: " << liczba << endl;
- } while ((liczba/10) % 10 != 0);
- cout << "Suma cyfr tej liczby wynosi: ";
- cout << liczba << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement