c++写程序:题目描述
定义一个新的运算符,A @ B等于A和B中所有可能的数字对的成绩,再相加求和。 例如A = 456, B = 78,那么我们的A @ B = 4 * 7 + 4 * 8 + 5 * 7 + 5 * 8 + 6 * 7 + 6 * 8 = 225。
输入输出格式
输入
输入包含多组测试数据,每组数据两个整数A和B,中间用空格分离(1 ≤ A ,2B≤10三十二次方)
输出
输出A和B按照我们的运算方式后的结果,每个结果输出一行。
样例
输入1
456 78
Copy
输出1
225
我写的:
#include<bits/stdc++.h>
using namespace std;
int main()
{
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
string str,str2;
long long int sum=0,t=0;
while(cin>>str>>str2)
{
for(long long int i=0;i<str.size();i++)
{
for(long long int j=0;j<str2.size();j++)
{
t=t+(str[i]-48)*(str2[j]-48);
}
}
cout<<t<<endl;
}
return 0;
}