Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <iomanip>
- using namespace std;
- double sumD(double x, int n)
- {
- return n == 1 ? x : x + sumD(x, n - 1);
- }
- double sumF(float x, int n)
- {
- return n == 1 ? x : x + sumD(x, n - 1);
- }
- int main()
- {
- setlocale(LC_ALL, "RU");
- double xD{ 0.1 };
- float xF{ 0.1f };
- cout << setprecision(18) << sumD(xD, 10) << endl;
- cout << setprecision(18) << sumD(xF, 10) << endl;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement