fork download
  1. #include <iostream>
  2. #include <algorithm>
  3. #include <string>
  4.  
  5. bool checkInputNum(std::string strNumber)
  6. {
  7. if (std::all_of(strNumber.begin(), strNumber.end(), [](unsigned char chNum) {return isdigit(chNum) || isalpha(chNum);}))
  8. return true;
  9.  
  10. return false;
  11. }
  12.  
  13. bool IsNumValid(std::string strRule, std::string strNum)
  14. {
  15. if (strRule.length() < strNum.length())
  16. return false;
  17.  
  18. std::string strRevNum(strNum.rbegin(), strNum.rend());
  19. std::string strRevRule(strRule.rbegin(), strRule.rend());
  20.  
  21. for (unsigned int i = 0 ; i < strRevRule.length() ; ++i)
  22. {
  23. if (isalpha(strRevRule[i]))
  24. continue;
  25.  
  26. if (isdigit(strRevRule[i]) && i < strRevNum.length() && strRevRule[i] == strRevNum[i])
  27. {
  28. continue;
  29. }
  30. else
  31. {
  32. return false;
  33. }
  34. }
  35.  
  36. return true;
  37. }
  38.  
  39. int main()
  40. {
  41. std::string strMultiplicand, strMultiplier, strAnswer;
  42.  
  43. //std::cin >> strMultiplicand;
  44. //std::cin >> strMultiplier;
  45. //std::cin >> strMultiplier;
  46.  
  47. strMultiplicand = "a1b2";
  48. strMultiplier = "3c";
  49. strAnswer = "4d5ef";
  50.  
  51. for (int i = 0 ; std::to_string(i).length() <= strMultiplicand.length() ; ++i)
  52. {
  53. if (!IsNumValid(strMultiplicand, std::to_string(i)))
  54. continue;
  55.  
  56. for (int j = 0 ; std::to_string(j).length() <= strMultiplier.length() ; ++j)
  57. {
  58. if (!IsNumValid(strMultiplier, std::to_string(j)))
  59. continue;
  60.  
  61. if (IsNumValid(strAnswer, std::to_string(i*j)))
  62. {
  63. std::cout << i << " * " << j << " = " << i*j << std::endl;
  64. }
  65. }
  66. }
  67.  
  68. system("PAUSE");
  69. return 0;
  70. }
  71.  
Success #stdin #stdout #stderr 0s 16064KB
stdin
Standard input is empty
stdout
1122 * 37 = 41514
1142 * 39 = 44538
1172 * 38 = 44536
1182 * 36 = 42552
1192 * 34 = 40528
stderr
sh: 1: PAUSE: not found