#include <stdio.h>
#include <time.h>
#define M 100000
int main() {
unsigned a[M]; //以无符号整形存,每100000为一进位,即数组每个元素最大9999
unsigned long k; //k用来保存每次乘积
int i,j,m,t,n=1,r; //n是数组长度,r是进位
time_t start, end;
a[0]=1;
while (1) {
printf(\n输入m t(用万进制办法求m的t次方):);fflush(stdout);
rewind(stdin);
if (2==scanf(%d %d,&m,&t)) {
if (m>1 && t>1) break;
else printf(请求m>1且t>1);
}
}
start = clock();
for (j=0;j<t;j++) {
r=0;
for (i=0;i<n;i++) {
k=a[i]m+r;
a[i]=k%10000;
r=k/10000;
}
while (r>0) {
a[n++]=r%10000;
if (n>=M-1) {
printf(%d的%d次方跨越万进制%d位,无法策画!\n,m,t,M);
return 1;
}
r/=10000;
}
}
printf(%d的%d次方=,m,t);
for (i=n-1;i>=0;i--) {
if(i==n-1) printf(%d ,a[i]);
else printf(%04d,a[i]);
}
end = clock();
printf(\n\n本次法度耗时: %lfs\n, (double(end)-double(start)) / CLOCKS_PER_SEC);
return 0;
}