题目描述
输入
两个小于1000000000的数
输出
输入可能有多组数据,对于每一组数据,输出Input中的两个数按照题目要求的方法进行运算后得到的结果。
样例输入
24 65
42 66666
3 67
样例输出
66
180
39
// stdafx.h : 标准系统包含文件的包含文件,
// 或是经常使用但不常更改的
// 特定于项目的包含文件
//
#pragma once
#include "targetver.h"
#include <stdio.h>
#include <tchar.h>
#include <stdlib.h>
#include <iostream>
#include <string>
using namespace std;
// TODO: 在此处引用程序需要的其他头文件
源文件
// ProblemC.cpp: 定义控制台应用程序的入口点。
//
#include "stdafx.h"
int main()
{
string a,b;
while (cin >> a >> b) {
int len1 = a.length();
int len2 = b.length();
int result = 0;
for (int i = 0; i < len1; i++) {
for (int j = 0; j < len2; j++) {
result += (a[i]-'0') * (b[j]-'0');
}
}
cout << result << endl;
}
return 0;
}
结果
问题: 1.char类型的运算没有第一时间反应过来 要转成int ..result += (a[i]-'0') * (b[j]-'0');
-'0' 很重要