Advertisement
Guest User

8.4

a guest
Apr 23rd, 2018
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.31 KB | None | 0 0
  1. #include <iostream>
  2. #include <conio.h>
  3. #include <cmath>
  4. #include <string>
  5. using namespace std;
  6.  
  7. int sum( int num)
  8. {
  9. if (num < 10)
  10. return num;
  11. else
  12. return (num%10)+sum(num/10);
  13. }
  14.  
  15. int main()
  16. {
  17. setlocale(LC_ALL, "Russian");
  18. cout << sum(39); //
  19. getch();
  20. return 0;
  21. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement