首页 > 其他 > 详细

【POJ】Cow Multiplication(水题)

时间:2018-04-20 21:12:09      阅读:172      评论:0      收藏:0      [点我收藏+]

Cow Multiplication

http://poj.org/problem?id=3673

题意:输入两个数A B,比如123和45   然后算123*45这个运算是指1*4 + 1*5 + 2*4 + 2*5 + 3*4 + 3*5 = 54.

思路:水题。

#include<iostream>
#include<cmath>
#include<cstring>
using namespace std;
typedef long long ll;
const int inf = 0x3f3f3f3f;
int main()
{

    char a[20], b[20];
    cin >> a >> b;
    int i, j, sum = 0, la, lb;
    la = strlen(a);
    lb = strlen(b);
    for(i = 0; i < la; i++)
    {
        for(j = 0; j < lb; j++)
        {
            sum += ((a[i] - 0) * (b[j] - 0));
        }
    }
    cout << sum << endl;


    return 0;
}

 

【POJ】Cow Multiplication(水题)

原文:https://www.cnblogs.com/Kohinur/p/8893287.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!