NUM为定值是可以运行,若用循环for(NUM=1;NUM<=20;NUM++)则出错
下面程序NUM为定值是可以运行,若用循环for(NUM=1;NUM<=20;NUM++)则出错int Counter[];
int Sum[];
Counter=new int[40];
Sum=new int[40];
int Num=20;
int Inum;
int Jcon=39;
int n;
int m;
for(Num=20;Num>0;Num--)
{
//////
for(int i=0;i<40;i++)//初始化数组
{
Counter[i]=0;
}
Counter[Jcon]=Num;
for(Inum=1;Inum<NUM;INUM++) 乘几次
{
for(n=0;n<40;n++)
{
Counter[n]=Counter[n]*Num;
}
for(Jcon=39;Jcon>0;Jcon--)
{
Counter[Jcon-1]=Counter[Jcon-1]+Counter[Jcon]/10;
Counter[Jcon]=Counter[Jcon]%100%10;
}
}
///////
/*for(int s=39;s>=0;s--)
{
Sum[s]=Sum[s]+Counter[s];
}
for(Jcon=39;Jcon>=1;Jcon--)
{
Sum[Jcon-1]=Sum[Jcon-1]+Sum[Jcon]/10;
Sum[Jcon]=Sum[Jcon]%10;
}*/
for(int h=0;h<=39;h++)
{
System.out.print(Counter[h]);
}
System.out.println();
}