九度OJ-1083-特殊乘法
2017-02-03 23:56
381 查看
题目地址:点击打开链接题目描述:
写个算法,对2个小于1000000000的输入,求结果。
特殊乘法举例:123 * 45 = 1*4 +1*5 +2*4 +2*5 +3*4+3*5
输入:
两个小于1000000000的数
输出:
输入可能有多组数据,对于每一组数据,输出Input中的两个数按照题目要求的方法进行运算后得到的结果。
样例输入:
样例输出:
来源:2010年清华大学计算机研究生机试真题答疑:解题遇到问题?分享解题心得?讨论本题请访问:http://t.jobdu.com/thread-7806-1-1.html
写个算法,对2个小于1000000000的输入,求结果。
特殊乘法举例:123 * 45 = 1*4 +1*5 +2*4 +2*5 +3*4+3*5
输入:
两个小于1000000000的数
输出:
输入可能有多组数据,对于每一组数据,输出Input中的两个数按照题目要求的方法进行运算后得到的结果。
样例输入:
123 45
样例输出:
54
来源:2010年清华大学计算机研究生机试真题答疑:解题遇到问题?分享解题心得?讨论本题请访问:http://t.jobdu.com/thread-7806-1-1.html
#include <iostream> using namespace std; int main(){ int a,b; int anum[10],bnum[10]; int acount,bcount; int temp,sum; while (cin>>a>>b){ //initiate sum=0; //process for (acount=0,temp=a;temp>0;acount++){ anum[acount]=temp%10; temp/=10; } for (bcount=0,temp=b;temp>0;bcount++){ bnum[bcount]=temp%10; temp/=10; } //sum up for (int i=0;i<acount;i++){ for (int j=0;j<bcount;j++){ sum+=anum[i]*bnum[j]; } } //output cout<<sum<<endl; } return true; }
相关文章推荐
- C++ 特殊乘法(九度OJ 1083)
- 九度OJ1083特殊乘法
- 九度OJ 题目1083:特殊乘法
- 【九度OJ】题目1083:特殊乘法 解题报告
- 九度OJ题目1083:特殊乘法
- 九度题目1083特殊乘法
- 九度 Online Judge 算法 刷题 题目1083:特殊乘法
- 九度题目:特殊乘法(1083)
- 九度 1083:特殊乘法(模拟)
- 九度OnlineJudge题目1083:特殊乘法
- 九度1083:特殊乘法
- 九度 题目1083:特殊乘法
- 九度1083 特殊乘法
- 九度OJ 1402 特殊的数
- 九度oj-1185-特殊排序
- 题目1083:特殊乘法(2010年清华大学计算机研究生机试真题)
- 九度oj 1083
- 九度OJ 1083 特殊乘法 (模拟)
- 九度OJ 1083: 特殊乘法
- 题目1083:特殊乘法[数位拆解]