zoj 1292 Integer Inquiry
来源:互联网 发布:php aes解密 编辑:程序博客网 时间:2024/04/30 17:56
百练的加强版~~其实也没加强多少
只是加了个输入多个数而已
#include <stdio.h>#include <string.h>#include <stdlib.h>int main(){ int ncase,i,len1,len2,maxlen,k = 0; int a,b; char s1[110],s2[110]; int num1[110],num2[110]; scanf("%d", &ncase); while( ncase-- ) {scanf("%s", s1); len1 = strlen(s1);maxlen = len1;k = 0;memset(num1,0,sizeof(num1)); //和for(i=0; i<110; i++) num1[i] = 0; 功能一样 for(i=len1-1; i>=0; i--) //num1存入数,未存入的项还为0 .{num1[k++] = s1[i] - '0'; }while( scanf("%s", s2) && strcmp(s2,"0") ) {k = 0;memset(num2,0,sizeof(num2)); //初始化num2 len2 = strlen(s2);for(i=len2-1; i>=0; i--){num2[k++] = s2[i] - '0'; //小小计数器~~ }for(i=0; i<len2; i++) //i<len2 不怕len2=1,因为后面都是0,还能加 {num1[i] += num2[i];}if (len2 > maxlen) //最大项 {maxlen = len2;}}for(i=0; i<maxlen; i++) //进位 { a = b = 0; if (num1[i] > 9) { a=num1[i]/10; b=num1[i]%10; num1[i] = b;num1[i+1] = num1[i+1] + a; //90+10=100,二位变三位 } a = b = 0;}if( num1[maxlen] != 0 ) //进位后,maxlen变大,so.. { maxlen++;} for(i=maxlen-1; i>=0; i--){printf("%d",num1[i]);}if (ncase) printf("\n\n");}system("pause");return 0;}
- ZOJ 1292 Integer Inquiry
- ZOJ 1292 Integer Inquiry
- zoj 1292 Integer Inquiry
- ZOJ 1292 Integer Inquiry
- ZOJ 1292 Integer Inquiry
- zoj 1292 Integer Inquiry
- zoj 1292 Integer Inquiry【大数】
- zoj 1292 Integer Inquiry(大数)
- ZOJ 1292/HDU 1047 Integer Inquiry
- Integer Inquiry
- Integer Inquiry
- Integer Inquiry
- Integer Inquiry
- Integer Inquiry
- Integer Inquiry
- Integer Inquiry
- Integer Inquiry
- Integer Inquiry
- CString截取字串方法
- POJ 2029 Get Many Persimmon Trees
- Android-语音识别
- struts2--配置文件通配符的使用
- 体验经济
- zoj 1292 Integer Inquiry
- CKEditor config.js文件配置
- html中的base解释
- 激荡三十年(珍藏图文版)
- Windows Mobile操作———— 拨号、发送消息、添加联系人、任务、约会等
- CTO谈豆瓣网和校内网技术架构变迁
- whois查询
- UISplitViewController代理方法
- 通过OCCI连接oracle(C++)