commit eac4ebd8f356053cfba29681b6f36df1129399f6 Author: hzp <1738971281@qq.com> Date: Sun Jan 13 20:59:39 2019 +0800 first commit diff --git a/排版系统1.cpp b/排版系统1.cpp new file mode 100644 index 0000000..695c32b --- /dev/null +++ b/排版系统1.cpp @@ -0,0 +1,77 @@ +#include "stdio.h" +int n=0; +int rest[7][7];//ÐÝÏ¢µÄ¿ÉÄÜʱ¼ä¡¢ +void swap(int *a,int *b)//ʵÏÖ½»»» +{ + int m; + m=*a; *a=*b; + *b=m; +} + //0 6 +void perm(int list[],int k,int m)//°ÑÊäÈëµÄÿ¸öÈ˵ĿÉÄÜÐÝϢʱ¼ä´«¸øº¯Êý¡¢ +{ + int i; int j; + if(k>m)//µ±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"); + 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"); + } + else//µ±K<=mµÄʱºò + { + 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};//Ò»ÖܵÄ7Ìì¡¢ + int i,j; + char ss[7][20]={"ÕÔ","Ç®","Ëï","Àî","ÖÜ","Îâ","³Â"}; + printf("============================ »¶ Ó­ ʹ Óà ÅÅ °à ϵ ͳ ============================"); + printf("ÇëÊäÈëÏÂÁÐÈËÑ¡ÔñÐÝÏ¢µÄ¿ÉÄÜʱ¼ä£º\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;//µ±ÊäÈëµÄÐÝϢʱ¼äλ-1ʱ¡¢¿ªÊ¼ÏÂÒ»¸öÈ˵ĿÉÄÜÐÝϢʱ¼ä + } + } + printf("\n\n\n"); + perm(list,0,6); + getchar(); + getchar();//getchar()º¯ÊýÒ²»á»ñÈ¡ÄãÊäÈëµÄ»Ø³µ×Ö·û'\n' + return 0; +} +