Mam taką funkcje
void suma(int a=1, int b=15, int f=19)
{
String c;
int d=0;
for (int i=a; i < b; i++)
{c = dynamic_cast<TEdit *>(FindComponent("Edit" + (String)i))->Text;
d=d - StrToInt(c);}
for (int i=b; i <b+3; i++)
{
c = dynamic_cast<TEdit *>(FindComponent("Edit" + (String)i))->Text;
d=d + StrToInt(c);
}
dynamic_cast<TLabel *>(FindComponent("Label" + (String)f))->Caption = IntToStr(d);
}
Pewne Edity sa sumowane pewne odejmowane ... i wartosci jest wpisywana do Labela okreslonego.
Chce zrobic za pomoca rekurencji, aby zaoszczedzic na kodzie.... i robie w ten sposob
void suma(int a=1, int b=15, int f=19)
{
String c;
int d=0;
for (int i=a; i < b; i++)
{c = dynamic_cast<TEdit *>(FindComponent("Edit" + (String)i))->Text;
d=d - StrToInt(c);}
for (int i=b; i <b+3; i++)
{
c = dynamic_cast<TEdit *>(FindComponent("Edit" + (String)i))->Text;
d=d + StrToInt(c);
}
if (b<204)
{
suma(a+17,b+17,f+1);
}
dynamic_cast<TLabel *>(FindComponent("Label" + (String)f))->Caption = IntToStr(d);
}
Mam 204 Edity wiec funkcja powinna sie wykonywac dopoki b bedzie mniejsze od 204 ... Zreszta pisze logiczne to powinno byc... program sie kompiluje ale przy uzyciu funkcji zawiesza sie i wyskakuje blad ... cos w styl ` is not integer value.... i odsyla mnie do linijki z rekurencja .... jak dla mnie to powinno dzialac ... no ale moze ma ktos pomysl czemu program sie sypie....