目前思考到这里了。还不完善。
程序代码:
#include <stdio.h>
#include <stdlib.h>
int main()
{
int a[21]={ 10 ,10, 10, 10, 87, 66 ,10, 10 ,10, 10, 10,10, 10, 10, 10, 10 ,85 ,47, 15, 10 ,10 },m1,m2,m3,k=1,p=21;
for(m1=1;m1<p;m1++)
{
if(a[0]==10)
{
if(a[m1]-a[0]==0)
{ printf("m1=%d ",m1);
k=k+1;
printf( "%d,%d ",0,m1);
printf( " k = %d ",k);
printf("\n");
for(m2=1;m2<p-m1;m2++)
if(a[m2]-a[0]==0)
{ printf("m2=%d ",m2);
k=k+1;
printf( "%d,%d,%d ",0,m1,m1+m2);
printf( " k = %d ",k);
printf("\n");
for(m3=1;m3<p-m1-m2;m3++)
if(a[3]-a[0]==0)
{ printf("m3=%d ",m3);
k=k+1;
printf( "%d,%d,%d ,%d",0,m1,m1+m2,m1+m2+m3);
printf( " k = %d ",k);
printf("\n");
if(a[4]-a[0]==0)
{ k=k+1;
printf( "%d,%d,%d ,%d,%d",0,1,2,3,4);
printf( " k = %d ",k);
printf("\n");
if(a[5]-a[0]==0)
{ k=k+1;
printf( "%d,%d,%d ,%d,%d,%d",0,1,2,3,4,5);
printf( " k = %d ",k);
printf("\n");
if(a[6]-a[0]==0)
{ k=k+1;
printf( "%d,%d,%d ,%d,%d,%d,%d",0,1,2,3,4,5,6);
printf( " k = %d ",k);
printf("\n");
if(a[7]-a[0]==0)
{ k=k+1;
printf( "%d,%d,%d ,%d,%d,%d,%d,%d",0,1,2,3,4,5,6,7);
printf( " k = %d ",k);
printf("\n");
if(a[8]-a[0]==0)
{ k=k+1;
printf( "%d,%d,%d ,%d,%d,%d,%d,%d,%d",0,1,2,3,4,5,6,7,8);
printf( " k = %d ",k);
printf("\n");
if(a[9]-a[0]==0)
{ k=k+1;
printf( "%d,%d,%d ,%d,%d,%d,%d,%d,%d,%d",0,1,2,3,4,5,6,7,8,9);
printf( " k = %d ",k);
printf("\n");
if(a[10]-a[0]==0)
{ k=k+1;
printf( "%d,%d,%d ,%d,%d,%d,%d,%d,%d,%d,%d",0,1,2,3,4,5,6,7,8,9,10);
printf( " k = %d ",k);
printf("\n");
if(a[11]-a[0]==0)
{ k=k+1;
printf( "%d,%d,%d ,%d,%d,%d,%d,%d,%d,%d,%d,%d",0,1,2,3,4,5,6,7,8,9,10,11);
printf( " k = %d ",k);
printf("\n");
if(a[12]-a[0]==0)
{ k=k+1;
printf( "%d,%d,%d ,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d",0,1,2,3,4,5,6,7,8,9,10,11,12);
printf( " k = %d ",k);
printf("\n");
if(a[13]-a[0]==0)
{ k=k+1;
printf( "%d,%d,%d ,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d",0,1,2,3,4,5,6,7,8,9,10,11,12,13);
printf( " k = %d ",k);
printf("\n");
if(a[14]-a[0]==0)
{ k=k+1;
printf( "%d,%d,%d ,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d",0,1,2,3,4,5,6,7,8,9,10,11,12,13,14);
printf( " k = %d ",k);
printf("\n");
if(a[15]-a[0]==0)
{ k=k+1;
printf( "%d,%d,%d ,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d",0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15);
printf( " k = %d ",k);
printf("\n");
if(a[16]-a[0]==0)
{ k=k+1;
printf( "%d,%d,%d ,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d",0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16);
printf( " k = %d ",k);
printf("\n");
if(a[17]-a[0]==0)
{ k=k+1;
printf( "%d,%d,%d ,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d",0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17);
printf( " k = %d ",k);
printf("\n");
if(a[18]-a[0]==0)
{ k=k+1;
printf( "%d,%d,%d ,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d",0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18);
printf( " k = %d ",k);
printf("\n");
if(a[19]-a[0]==0)
{ k=k+1;
printf( "%d,%d,%d ,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d",0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19);
printf( " k = %d ",k);
printf("\n");
if(a[20]-a[0]==0)
{ k=k+1;
printf( "%d,%d,%d ,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d",0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20);
printf( " k = %d ",k);
printf("\n");
if(a[21]-a[0]==0)
{ k=k+1;
printf( "%d,%d,%d ,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d",0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21);
printf( " k = %d ",k);
printf("\n");
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
k=0;
}
k=0;
}
k=0;
}
k=0;
system ("pause");
}
printf("\n");
return 0;
}
[此贴子已经被作者于2020-10-6 20:40编辑过]