felippereis 0 Posted January 15 Report Share Posted January 15 private int a, b, c; private int calc(int p) { c += 1; if (p < 2) { return 4; } else { return c + calc(p - 1); } } void main() { b = 3; c = 0; a = calc(b); Console.WriteLine(a); Console.WriteLine(b); Console.WriteLine(c); } Qual a quantidade de vezes que a função foi executada e o valor final para cada variável. Quote Link to post Share on other sites
Question
felippereis 0
private int a, b, c;
private int calc(int p)
{
c += 1;
if (p < 2) {
return 4;
}
else
{ return c + calc(p - 1);
}
}
void main()
{
b = 3;
c = 0;
a = calc(b);
Console.WriteLine(a);
Console.WriteLine(b);
Console.WriteLine(c);
}
Qual a quantidade de vezes que a função foi executada e o valor final para cada variável.
Link to post
Share on other sites
0 answers to this question
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.