You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
42 lines
945 B
42 lines
945 B
#include <stdio.h>
|
|
#include <string.h>
|
|
#include <stdlib.h>
|
|
int ans[11];
|
|
void f(char str[], int l0, int l) {
|
|
if (l0 == l) {
|
|
for (int i = 1; i <= ans[0]; i++) {
|
|
printf("%c", str[ans[i]]);
|
|
}
|
|
printf("\n");
|
|
return;
|
|
}
|
|
for (int i = 0; i < l0; i++) {
|
|
int flag = 1;
|
|
for (int j = 1; j <= ans[0]; j++) {
|
|
if (i == ans[j]) {
|
|
flag = 0;
|
|
break;
|
|
}
|
|
}
|
|
if (flag == 1) {
|
|
ans[++ans[0]] = i;
|
|
f(str, l0, l + 1);
|
|
ans[0]--;
|
|
}
|
|
}
|
|
}
|
|
void Cal(char* str)
|
|
{
|
|
int len = strlen(str);
|
|
for (int i = 0; i < len - 1; i++) {
|
|
for (int j = 0; j < len - 1 - i; j++) {
|
|
int tmp;
|
|
if (str[j] > str[j + 1]) {
|
|
tmp = str[j];
|
|
str[j] = str[j + 1];
|
|
str[j + 1] = tmp;
|
|
}
|
|
}
|
|
}
|
|
f(str, len, 0);
|
|
} |