1~24顺次排列。每三个一组。共八组。问这八组可以排列出多少不同顺序。(光是八个顺序改变。组内顺序不变

来源:百度知道 编辑:UC知道 时间:2024/05/07 20:45:44
是用C语言做得~急 ~~在线等~~~谢谢啦

#include <stdio.h>
#include<string.h>

long count(int isFile)
{
FILE * fp=fopen("file.txt","w+");
if(fp==NULL) printf("XXXXX\n");
char * str[]={"01 02 03","04 05 06","07 08 09","10 11 12","13 14 15","16 17 18","19 20 21","22 23 24"};
long num=0;
for(int a=0;a<8;a++)
for(int b=0;b<8;b++)
for(int c=0;c<8;c++)
for(int d=0;d<8;d++)
for(int e=0;e<8;e++)
for(int f=0;f<8;f++)
for(int g=0;g<8;g++)
for(int h=0;h<8;h++)
{
if(a==b || a==c ||a==d ||a==e ||a==f ||a==g ||a==h ||b==c||b==d ||b==e||b==f||b==g||b==h ||c==d||c==e||c==f||c==g||c==h ||d==e||d==f||d==g||d==h ||e==f||e==g||e==h ||f==g||f==h ||g==h) continue;
num++;

if(isFile==1) fprintf(fp,"%s %s %s %s %s %s %s %s\n",str[a],str[b],st