应用多文件数组处理大整数的加减乘除.doc

应用多文件数组处理大整数的加减乘除.doc

ID:53959567

大小:28.00 KB

页数:7页

时间:2020-04-11

应用多文件数组处理大整数的加减乘除.doc_第1页
应用多文件数组处理大整数的加减乘除.doc_第2页
应用多文件数组处理大整数的加减乘除.doc_第3页
应用多文件数组处理大整数的加减乘除.doc_第4页
应用多文件数组处理大整数的加减乘除.doc_第5页
资源描述:

《应用多文件数组处理大整数的加减乘除.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;j

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;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

当前文档最多预览五页,下载文档查看全文

此文档下载收益归作者所有

当前文档最多预览五页,下载文档查看全文
温馨提示:
1. 部分包含数学公式或PPT动画的文件,查看预览时可能会显示错乱或异常,文件下载后无此问题,请放心下载。
2. 本文档由用户上传,版权归属用户,天天文库负责整理代发布。如果您对本文档版权有争议请及时联系客服。
3. 下载前请仔细阅读文档内容,确认文档内容符合您的需求后进行下载,若出现内容与标题不符可向本站投诉处理。
4. 下载文档时可能由于网络波动等原因无法下载或下载错误,付费完成后未能成功下载的用户请联系客服处理。