faça um algoritimo que leia x e y inteiros e calcule e screva o resultado x elevado a y ?
var
x, y : integer;
z : real;
begin
clrscr;
writeln('Digite o Valor de X: ');
readln(x);
writeln('Digite o Valor de Y: ');
readln(y);
z := exp(y*ln(x));
writeln(z);
readkey;
end.
O algoritmo será:
{
if (y == 0)
devolução 1;
else if (y% 2 == 0)
poder de retorno (x, y / 2) * potência (x, y / 2);
outro
return x * power (x, y / 2) * potência (x, y / 2);
}
/ * Programa para testar o poder da função * /
int main ()
{
int x = 2;
não assinado int y = 3;
printf ("% d", power (x, y));
return 0;
}
Para escrever sua resposta aqui, entre ou crie uma conta.
Compartilhar