#include
#include
void swap(int c[], int len)
{
int i = 0;
int tmp;
for (; i < len; ++i, --len)
{
tmp = c[i];
c[i] = c[len];
c[len] = tmp;
}
}
int mul(char a[], char b[], int c[])
{
int c1,c2,i,k;
c1=strlen(a);
c2=strlen(b);
for(i=0;i
k=999;
while(c[k]==0)
k--;
for(i=0;i<=k;i++)
{
c[i+1]+=c[i]/10;
c[i]%=10;
}
while(c[i]>0)
i++;
swap(c, i-1);
for (k = 0; k < i; ++k)
printf("%d", c[k]);
printf("\n");
return i;
}
void mycopy(char b[], int c[], int len)
{
int i;
for (i = 0; i < len; ++i)
sprintf(b+i, "%d", c[i]);
}
int main()
{
char a[1000] = {0}, b[1000] = {0};
int c[1000] = {1};
int i;
int len = 1;
for (i = 2; i <= 100; i+=2)
{
memset(b, 0, 1000);
mycopy(b, c, len);
sprintf(a, "%d", i);
memset(c, 0, 4*len);
len = mul(a, b, c);
}
return 0;
}
---------------------------------以下是结果------------------------------------
34243224702511976248246432895208185975118675053719198827915654463488000000000000
int fun()
{
int a;
for(int i=1;i<99;i++)
{
i++;
a*=i;
}
return a;
}
从1到100的50个偶数乘积
上面的错了 应该是
int fun(){
int i,sum=1;
for(i=1;i<=100;i++)
return sum;
}
main(){
int n;
n=fun();
printf("%d",n);
getch();
}
值会越界的,参考一下大数的运算吧