Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int a,b;
- int suma_cyfr(int a)
- { int b=1;
- int c=1;
- while(a%10==0)
- {a=a/10;}
- while (b<=a)
- {b=b*10;}
- while(a>1)
- {while(a>b)
- {
- a=a-b;
- c++;
- }
- b=b/10;
- }
- return c;
- }
- int main()
- {
- b=10;
- while(b>=10)//liczba mniejsza od 10 kończy program
- {
- cout<<"podaj liczbe naturalna lub wynik poprzedniej sumy"<<endl;
- cin>>a;
- b=suma_cyfr(a);
- cout<<"suma cyfr wynosi "<< suma_cyfr(a)<<endl;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement