zoukankan      html  css  js  c++  java
  • POJ 3673 Cow Multiplication (水题)

    题意:给你两个数,求所有的数位的积的和。

    析:太水了,没的说,可以先输入边算,也可以最后再算,一样。。

    代码如下:

    #include <cstdio>
    #include <string>
    #include <cstdlib>
    #include <cmath>
    #include <iostream>
    #include <cstring>
    #include <set>
    #include <queue>
    #include <algorithm>
    #include <vector>
    #include <map>
    using namespace std ;
    
    typedef long long LL;
    typedef pair<int, int> P;
    const int INF = 0x3f3f3f3f;
    const double inf = 0x3f3f3f3f3f3f3f;
    const double eps = 1e-8;
    const int maxn = 1000 + 5;
    const int dr[] = {0, 0, -1, 1};
    const int dc[] = {-1, 1, 0, 0};
    int m, n;
    inline bool is_in(int r, int c){
        return r >= 0 && r < n && c >= 0 && c < m;
    }
    
    int main(){
        while(scanf("%d %d", &n, &m) == 2){
            int a[15], b[15];
            int cnt1 = 0, cnt2 = 0;
            while(n){
                a[cnt1++] = n % 10;
                n /= 10;
            }
            while(m){
                b[cnt2++] = m % 10;
                m /= 10;
            }
            int ans = 0;
            for(int i = 0; i < cnt1; ++i)
                for(int j = 0; j < cnt2; ++j)
                    ans += a[i] * b[j];
            printf("%d
    ", ans);
        }
        return 0;
    }
    
  • 相关阅读:
    20、【Linux系统编程】 exec系列函数
    3、【Linux网络编程】socket实例
    c++ 二分答案(基础应用)
    c++ 迷宫搜索(宽搜)
    c++ 广度优先搜索(宽搜)
    栈的概念
    c++ 栈的基本应用
    队列的概念
    c++ 队列的基本应用
    Knight Moves
  • 原文地址:https://www.cnblogs.com/dwtfukgv/p/5754402.html
Copyright © 2011-2022 走看看