C语言小练习

来源:百度知道 编辑:UC知道 时间:2024/09/28 14:04:21
输出 a b c d e五个字符的所以排列
不能重复。
不要有字符重复的
要例如: a b c d e ,b c d a e

#include <iostream>
using namespace std;

template <typename T>
void Perm(T Test[], int low, int high)
{
if(low == high){
for(int i = 0; i <= high; ++i)
cout << Test[i] << '\t';
cout << highl;
}
else{
for(int i = low; i <= high; ++i){
swap(Test[low], Test[i]);
Perm(Test, low + 1, high);
swap(Test[low], Test[i]);
}
}
}

int main()
{
char a[] = {'a', 'b', 'c', 'd'};
int min = 0;
int max = sizeof a / sizeof *a - 1;
Perm(a, min, max);
cin.get();
return 0;
}

#include<stdio.h>
void f(char *s,int m, int n)
{
    int i,j,k;
    if(m==n) printf("%s\n&