#include "stdafx.h"2QELinux联盟
#include "stdio.h"2QELinux联盟
#include "iostream.h"
int main(int argc, char* argv[])2QELinux联盟
{2QELinux联盟
int carry,n,j;2QELinux联盟
int a[2000];2QELinux联盟
int digit=1;2QELinux联盟
int temp,i;2QELinux联盟
cout<<"please enter n:"<<endl;2QELinux联盟
cin>>n;2QELinux联盟
a[0]=1;2QELinux联盟
for(i=2; i<=n; i++)2QELinux联盟
{2QELinux联盟
for(carry=0,j=1; j<=digit; ++j)2QELinux联盟
{2QELinux联盟
temp=a[j-1]*i+carry;2QELinux联盟
a[j-1]=temp%10;2QELinux联盟
carry=temp/10;2QELinux联盟
}2QELinux联盟
while(carry)2QELinux联盟
{2QELinux联盟
//digit++;2QELinux联盟
a[++digit-1]=carry%10;2QELinux联盟
carry/=10;2QELinux联盟
}2QELinux联盟
}2QELinux联盟
cout<<"the result is:"<<endl;2QELinux联盟
for(int k=digit; k>=1; --k)2QELinux联盟
cout<<a[k-1];2QELinux联盟
cout<<endl;2QELinux联盟
return 0;2QELinux联盟
}
Linux联盟收集整理 ,转贴请标明原始链接,如有任何疑问欢迎来本站Linux论坛讨论