主题:高手请进!!!!!!!!!!
g1021117
[专家分:40] 发布于 2007-12-31 15:16:00
谁知道m的n次幂怎么编??????????//[em4][em4][em4][em4][em4][em4][em4][em4][em4][em4][em5][em5][em5][em5][em5][em5][em5]
回复列表 (共7个回复)
沙发
angwuy [专家分:2280] 发布于 2007-12-31 19:41:00
var
a:array[1..500]of integer;
i,j,k,m,n:integer;
begin
readln(m,n);
fillchar(a,sizeof(a),0);
a[1]:=1;
for i:=1 to n do
begin
for j:=1 to 500 do
a[j]:=a[j]*m;
for j:=1 to 500 do
if a[j]>9 then
begin
a[j+1]:=a[j] div 10;
a[j]:=a[j] mod 10;
end;
end;
j:=500;
while a[j]=0 do dec(j):
for i:=j downto 1 do
write(a[i]);
writeln;
end.
随手打的,你自己看看吧
板凳
g1021117 [专家分:40] 发布于 2008-01-03 10:36:00
好
象
有
问
题,
我
要
高
精
度
的·!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
3 楼
angwuy [专家分:2280] 发布于 2008-01-03 12:50:00
这就是高精度的
4 楼
shisutianxia [专家分:630] 发布于 2008-01-05 14:23:00
抓住高精法则!!!!!我的程序
program dfdf;
var a,b,c:array[0..100]of 0..9 ;
x,w,i,j,l,n,p:integer;m:string;
begin
writeln('m de n cifang--input m n');
writeln('m=');
readln(m);
writeln('n=');
readln(n);
l:=length(m);
for i:=l downto 1 do
begin
a[l-i+1]:=ord(m[i])-ord('0');
b[l-i+1]:=ord(m[i])-ord('0');
end;
a[0]:=l;b[0]:=l;
for l:=1 to n-1 do
begin
fillchar(c,sizeof(c),0);
for i:=1 to a[0] do
for j:=1 to b[0] do
begin
x:=a[i]*b[j];
w:=i+j-1;
p:=c[w]+x;
c[w]:=p mod 10;
c[w+1]:=c[w+1]+p div 10;
end;
w:=a[0]+b[0];
while c[w]=0 do dec(w);
fillchar(a,sizeof(a),0);
for i:=1 to w do
a[i]:=c[i];
a[0]:=w;
end;
for i:=a[0] downto 1 do
write(a[i]);
writeln;
writeln('weishu=a[0]');
end.
5 楼
g1021117 [专家分:40] 发布于 2008-01-05 16:05:00
writeln('weishu=a[0]');
错了,WRITELN(‘WEISHU=‘,A[0]); 还差不多?????????
6 楼
bc594926180 [专家分:0] 发布于 2008-01-26 19:52:00
program ex1;
var m,n,i,j,s,k:integer;
a:array[1..1001] of longint;
begin
readln(m,n);
for i:=1 to 1000 do a[i]:=0;
a[1]:=1;
for i:=1 to n do
begin
for j:=1 to 1000 do a[j]:=a[j]*m;
for j:=1 to 1000 do
begin
a[j+1]:=a[j] div 10 +a[j+1];
a[j]:=a[j] mod 10;
end;
end;
k:=1000;
while a[k]=0 do
k:=k-1;
for i:=k downto 1 do write(a[i]);
end.
7 楼
游侠UFO [专家分:1200] 发布于 2008-01-28 21:05:00
循环...乘...
还有个用数学只是的方法...
我来回复