Thứ Ba, 3 tháng 5, 2022

XAUHV C++

#include<bits/stdc++.h>
using namespace std;
char x[10];
string c,a;
int n;
int d[1000];
void xuat()
{
    for(int i=1;i<=n;i++)
        cout <<x[i];
    cout << endl;
}
void vet(int i)
{
    for(int j=65; j<=91; j++)
    {
        if(d[j]>0)
        {
            x[i]=char(j);
            d[j]--;
            if(i==n)
            {
                xuat();
            }
            else vet(i+1);
            d[j]++;
        }
    }
}
void nhap()
{
    cin>>a;
    n=a.length();
    for(int i=0; i<=n-1; i++) d[int(a[i])]++;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    freopen("XAUHV.inp","r",stdin);
    freopen("XAUHV.out","w",stdout);
    nhap();
    vet(1);
}

Không có nhận xét nào:

Đăng nhận xét

Lưu ý: Chỉ thành viên của blog này mới được đăng nhận xét.