Advertisement
Pafnytiu

рекурсия 2 - 9

Feb 29th, 2016
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.25 KB | None | 0 0
  1. #include<iostream>
  2. using namespace std;
  3. int Func(int n)
  4. {
  5. if (n==1 || n<1)
  6. return 1;
  7. else
  8. return n+Func(n-1);
  9. }
  10. int main()
  11. { int m,k;
  12. cout << "m = "; cin >> m;
  13. cout << "k = "; cin >> k;
  14. cout<< Func(m)+Func(2*k)<<endl;
  15. return 0;
  16. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement