欢迎来到天天文库
浏览记录
ID:53959567
大小:28.00 KB
页数:7页
时间:2020-04-11
《应用多文件数组处理大整数的加减乘除.doc》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、#include"stdio.h"#include"stdlib.h"#include"string.h"#include"f2.h"#include"f3.h"#include"f4.h"#include"f5.h"#definemax_len100intan1[max_len+10]={0};intan2[max_len+10]={0};intresult[max_len+10]={0};charstr1[max_len+10];charstr2[max_len+10];voidmain(){intflag=1;printf("=================");printf
2、("====1:求和=========");printf("====2:求差======");printf("====3:求积======");printf("====4:求商=========");printf("====5:退出=========");printf("=================");while(flag!=0){printf("Pleaseinputyourchoice:");scanf("%d",&flag);switch(flag){default:printf("Thenumisnotcorrect,pleaseinputag
3、ain:");break;case1:add(an1,an2);break;case2:jian(an1,an2);break;case3:mul(an1,an2);break;case4:div(an1,an2);break;case5:exit(0);}}}#include"f2.h"#include"stdio.h"#include"stdlib.h"#include"string.h"#definemax_len100intadd(int*an1,int*an2){charstr1[max_len+10];charstr2[max_len+10];scanf("%s",str
4、1);scanf("%s",str2);inti,j;//存储的字符串整数转换到an1中去j=0;for(i=strlen(str1)-1;i>=0;i--)an1[j++]=str1[i]-'0';j=0;for(i=strlen(str2)-1;i>=0;i--)an2[j++]=str2[i]-'0';for(i=0;i=10){//看是否进位an1[i]-=10;an1[i+1]++;//进位}}boolbStartOutput=false;//跳过多余的零for(i=max_len;i>=
5、0;i--){if(bStartOutput)printf("%d",an1[i]);//多余零都跳过则退出elseif(an1[i]){printf("Thesumis%d",an1[i]);bStartOutput=true;}}for(j=0;j6、n+10];charstr2[max_len+10];inti,j;scanf("%s",str1);scanf("%s",str2);for(i=0;i=0;i--)an1[j++]=str1[i]-'0';intnlen2=strlen(str2);j=0;for(i=nlen2-1;i>=0;i--)an2[j++]=str2[i]-'0';for(i=0;i7、[i]+=10;an1[i+1]--;}an1[i]-=an2[i];}boolbStartOutput=false;//跳过多余的零for(i=max_len;i>=0;i--){if(bStartOutput)printf("%d",an1[i]);//多余零都跳过则输出elseif(an1[i]){printf("Theresultis%d",an1[i]);bStartOutput=true;}}for(i=0;i
6、n+10];charstr2[max_len+10];inti,j;scanf("%s",str1);scanf("%s",str2);for(i=0;i=0;i--)an1[j++]=str1[i]-'0';intnlen2=strlen(str2);j=0;for(i=nlen2-1;i>=0;i--)an2[j++]=str2[i]-'0';for(i=0;i7、[i]+=10;an1[i+1]--;}an1[i]-=an2[i];}boolbStartOutput=false;//跳过多余的零for(i=max_len;i>=0;i--){if(bStartOutput)printf("%d",an1[i]);//多余零都跳过则输出elseif(an1[i]){printf("Theresultis%d",an1[i]);bStartOutput=true;}}for(i=0;i
7、[i]+=10;an1[i+1]--;}an1[i]-=an2[i];}boolbStartOutput=false;//跳过多余的零for(i=max_len;i>=0;i--){if(bStartOutput)printf("%d",an1[i]);//多余零都跳过则输出elseif(an1[i]){printf("Theresultis%d",an1[i]);bStartOutput=true;}}for(i=0;i
此文档下载收益归作者所有