Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // ConsoleApplication27.cpp: определяет точку входа для консольного приложения.
- //
- #include "stdafx.h"
- #include "stdio.h"
- #include <iostream>
- #include <cmath>
- using namespace std;
- int sum(int a){
- if (a > 10){
- return sum(a % 10 + sum(a / 10));
- }
- else return a;
- }
- int _tmain(int argc, _TCHAR* argv[])
- {
- int n;
- cin >> n;
- cout << sum(n)<<endl;
- system("pause");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement