#include <iostream>
#include <algorithm>
#include <string>
bool checkInputNum(std::string strNumber)
{
if (std::all_of(strNumber.begin(), strNumber.end(), [](unsigned char chNum) {return isdigit(chNum) || isalpha(chNum);}))
return true;
return false;
}
bool IsNumValid(std::string strRule, std::string strNum)
{
if (strRule.length() < strNum.length())
return false;
std::string strRevNum(strNum.rbegin(), strNum.rend());
std::string strRevRule(strRule.rbegin(), strRule.rend());
for (unsigned int i = 0 ; i < strRevRule.length() ; ++i)
{
if (isalpha(strRevRule[i]))
continue;
if (isdigit(strRevRule[i]) && i < strRevNum.length() && strRevRule[i] == strRevNum[i])
{
continue;
}
else
{
return false;
}
}
return true;
}
int main()
{
std::string strMultiplicand, strMultiplier, strAnswer;
//std::cin >> strMultiplicand;
//std::cin >> strMultiplier;
//std::cin >> strMultiplier;
strMultiplicand = "a1b2";
strMultiplier = "3c";
strAnswer = "4d5ef";
for (int i = 0 ; std::to_string(i).length() <= strMultiplicand.length() ; ++i)
{
if (!IsNumValid(strMultiplicand, std::to_string(i)))
continue;
for (int j = 0 ; std::to_string(j).length() <= strMultiplier.length() ; ++j)
{
if (!IsNumValid(strMultiplier, std::to_string(j)))
continue;
if (IsNumValid(strAnswer, std::to_string(i*j)))
{
std::cout << i << " * " << j << " = " << i*j << std::endl;
}
}
}
system("PAUSE");
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8YWxnb3JpdGhtPgojaW5jbHVkZSA8c3RyaW5nPgoKYm9vbCBjaGVja0lucHV0TnVtKHN0ZDo6c3RyaW5nIHN0ck51bWJlcikKewoJaWYgKHN0ZDo6YWxsX29mKHN0ck51bWJlci5iZWdpbigpLCBzdHJOdW1iZXIuZW5kKCksIFtdKHVuc2lnbmVkIGNoYXIgY2hOdW0pIHtyZXR1cm4gaXNkaWdpdChjaE51bSkgfHwgaXNhbHBoYShjaE51bSk7fSkpCgkJcmV0dXJuIHRydWU7CgoJcmV0dXJuIGZhbHNlOwp9Cgpib29sIElzTnVtVm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