真不明白,这就才20?
查看原帖
真不明白,这就才20?
1274005
cy156楼主2024/3/3 14:09
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
	int n,count=1,k=0;
	char ch[10],str[10];
	//scanf("%d",&n);
	cin>>n;
	cin>>ch;
	for(int i=0;i<n;i++)
        str[i]=ch[i];
	sort(ch,ch+n);
	do{
        for(int i=0;i<n;i++)
            //cout<<ch[i];
            {
                if(str[i]==ch[i])
                k++;
            }
        if(k==3)
        {
            cout<<count;
        }
        count++;
        k=0;
	}while(next_permutation(ch,ch+n));
	return 0;
}

2024/3/3 14:09
加载中...