题解 | #特殊乘法#

特殊乘法

https://www.nowcoder.com/practice/a5edebf0622045468436c74c3a34240f

#include<cstdio>
#include<vector>
using namespace std;
int main(){
	long long n, m;
	vector<int>vec1;
	vector<int>vec2;
	while (scanf("%lld %lld", &n, &m) != EOF){
		int x, y;
		while (n != 0){
			x = n % 10;
			vec1.push_back(x);
			n = n / 10;
		}
		while (m != 0){
			y = m % 10;
			vec2.push_back(y);
			m = m / 10;
		}
		int sum = 0;
		for (int i = 0; i < vec1.size(); i++){
			for (int j = 0; j < vec2.size(); j++){
				sum = vec1[i] * vec2[j] + sum;
			}
		}
		printf("%d", sum);
	}
}

全部评论

相关推荐

点赞 评论 收藏
分享
09-19 13:59
门头沟学院 Java
用微笑面对困难:Trae一下,如果真成了,他用了直接发字节起诉代码版权,,这个代码不商用是没问题的如果没成也是情理之中的。
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务