
 
#include <iostream>
#include <string>
using namespace std;
// 交换字符串中两个字符的位置
void swap(char& a, char& b)
{
    char temp = a;
    a = b;
    b = temp;
}
void fun(string str) {
    string a = str.substr(0,4);    
    int aa;
    sscanf(a.c_str(), "%d", &aa);
    string b = str.substr(4,1);
    int bb;
    sscanf(b.c_str(), "%d", &bb);
    string c = str.substr(5, 4);
    int cc;
    sscanf(c.c_str(), "%d", &cc);
    if (aa == bb * cc) {
        cout << aa << " = " << bb << " x " << cc << endl;
    }
    b = str.substr(4, 2);    
    sscanf(b.c_str(), "%d", &bb);
    c = str.substr(6, 3);    
    sscanf(c.c_str(), "%d", &cc);
    if (aa == bb * cc) {
        cout << aa << " = " << bb << " x " << cc << endl;
    }
    
}
// 字符串全排列函数
void permutation(string str, int begin, int end)
{
    if (begin == end) // 当begin等于end时,表示已经得到一个排列
    {
      fun(str); // 输出该排列
    }
    else
    {
        for (int i = begin; i <= end; i++)
        {
            // 将第i个字符与第begin个字符交换位置
            swap(str[begin], str[i]);
            // 对begin+1到end的子串进行全排列
            permutation(str, begin + 1, end);
            // 将第i个字符与第begin个字符交换位置,恢复原来的顺序
            swap(str[begin], str[i]);
        }
    }
}
 
int main()                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     
{
    
    string str = "123456789";
    permutation(str, 0, str.size() - 1);
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 
}
 
                


















