commit 022d9854dd26a8fec55047de8aad1a4709ff24c1 Author: 15364451585 <505935885@qq.com> Date: Thu Jan 10 20:43:54 2019 +0800 first commit diff --git a/未命名1.cpp b/未命名1.cpp new file mode 100644 index 0000000..46263c2 --- /dev/null +++ b/未命名1.cpp @@ -0,0 +1,90 @@ +#include +int n = 0; +int rest[7][7]; +void swap(int *a, int *b) +{ +int m; +m = *a; +*a = *b; +*b = m; +} +void perm(int list[], int k, int m) +{ +int i; +int j; +if(k > m) +{ +for (i=0; i<7; i++) +{ +for (j=0; j<7; j++) +{ +if (rest[i][j] == -1) +return; +if (rest[i][j] != list[i]) +continue; +if (rest[i][j] == list[i]) +break; +} +} +n++; +printf("Solution: %d\n", n); +printf(" Ǯ \n"); +for(i = 0; i <= m; i++) +{ +switch (list[i]) +{ +case 1: printf("һ "); +break; +case 2: printf("ڶ "); +break; +case 3: printf(" "); +break; +case 4: printf(" "); +break; +case 5: printf(" "); +break; +case 6: printf(" "); +break; +case 7: printf(" "); +break; +default: +break; +} +} +printf("\n\n\n"); +} +else +{ +for(i = k; i <= m; i++) +{ +swap(&list[k], &list[i]); +perm(list, k + 1, m); +swap(&list[k], &list[i]); +} +} +} +int main() +{ +int list[] = {1, 2, 3, 4, 5, 6, 7}; +int i, j; +char ss[7][20]={"","Ǯ","","","","",""}; +printf("===========================ӭʹŰϵͳ===================================\n"); +printf("ѡѡϢĿʱ,ÿһ˵Ϣʱ䣬-1󰴻س\n"); +for(i = 0; i < 7; i++) +{ + printf("%s",ss[i]); +for(j = 0; j < 7; j++) +{ +scanf("%d", &rest[i][j]); +if(rest[i][j] == -1) +break; +} +} +printf("\n\n\n"); +perm(list, 0, 6); +printf("ܵķ:%d", n); + +getchar(); +return 0; +} +