Advertisement
add1ctus

Збир на цифри

Sep 30th, 2015
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.27 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int zbir_na_cifri(int a)
  6. {
  7. int zbir=0;
  8. while(a>0)
  9. {
  10. zbir=zbir+a%10;
  11. a=a/10;
  12. }
  13. return zbir;
  14. }
  15.  
  16. int main()
  17. {
  18. int a;
  19. cin>>a;
  20. cout<<zbir_na_cifri(a);
  21. return 0;
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement