
Сообщение от
castaway
У тебя бесконечная рекурсия, из-за этого и ошибка. Стек переполняется.
Добавил условие остановки.В итоге зацикливание.Видимо не умею работать с рекурсией.
C++ |
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
| #include <iostream>
#include <conio.h>
#include <math.h>
using namespace std;
int x,a,b,c;
double func(int);
void main()
{
int n;
cout<<"Input n ";
cin>>n;
system("cls");
cout<<"Input x ";
cin>>x;
system("cls");
cout<<"Input a ";
cin>>a;
system("cls");
cout<<"Input b ";
cin>>b;
system("cls");
cout<<"Input c ";
cin>>c;
system("cls");
cout<<"Rezult: "<<func(n);
getch();
}
double func(int n)
{
double rez=0;
while(n>=0)
{rez=2*(n-1)*a*func(n-2)+(2*a*x+b)*func(n-1);}
n--;
return exp(rez);} |
|