主题:帮忙找找这道题有什么错误,加分!!!
program mi;
var x,y:integer;
function fang(n,m:integer):longint;
var i,k:integer;
begin
if n<>0 then
begin
if m=0 then fang:=1 else
if m=1 then fang:=n else
begin
k:=n;
for i:=2 to m do
k:=k*n;
fang:=k;
end;
end else
writeln('input error!');
end;
begin
writeln('input x= ,y=');
readln(x,y);
writeln(fang(x,y));
end.
这是一道求x的y次方的题
var x,y:integer;
function fang(n,m:integer):longint;
var i,k:integer;
begin
if n<>0 then
begin
if m=0 then fang:=1 else
if m=1 then fang:=n else
begin
k:=n;
for i:=2 to m do
k:=k*n;
fang:=k;
end;
end else
writeln('input error!');
end;
begin
writeln('input x= ,y=');
readln(x,y);
writeln(fang(x,y));
end.
这是一道求x的y次方的题