要说的都在注释里
#include#include #define MAX 10010 #define LL strlen char INT_MAX[15]="2147483648"; int judge(char *str) { int len=LL(str),ok=LL(INT_MAX); if(len 0)return 0; else return 1; } void jia(const char *str1,char *str)//add str1 to str { int len1=LL(str1); int c=0;len1--; for(int i=MAX-2;i>=0;i--) { if(len1>=0)str[i]+=str1[len1--]-'0'; str[i]+=c; c=(str[i]-'0')/10; str[i]=(str[i]-'0')%10+'0'; } str[MAX-1]='\0'; } void cheng(const char *str1,const char *str2,char *str)//高精度乘法 { int len1=LL(str1),len2=LL(str2),i,j; char ch[MAX];int k=2; for(i=len1-1;i>=0;i--) { memset(ch,'0',sizeof(ch));ch[MAX-1]='\0'; int c=0,f=MAX-k;//c为进位所加的数,f为最后一位的起始位 for(j=len2-1;j>=0;j--) { int temp=(str1[i]-'0')*(str2[j]-'0')+c; c=temp/10; ch[f--]=temp%10+'0'; } ch[f]+=c;int m=0; while(m