当前位置: 代码迷 >> C语言 >> [求助]
  详细解决方案

[求助]

热度:243   发布时间:2005-09-29 12:45:00.0
[求助]
#include "stdio.h"
#include "stdlib.h"
int times=0;
int Total_Num;
void OutTeam(Buffer,Num)
int *Buffer;
int Num;
{int i;
for (i=0;i<Num;i++)
  printf("%3d",Buffer[i]);
printf("\n");
times++;
}
void MovePosition(Position,DesNum,Buffer)
int Position,DesNum;
int *Buffer;
{Buffer[Position]=DesNum;
OutTeam(Buffer,Position+1);
}
void SubAssign(Buffer,Position,Orig_Value,DesValue,Standard)
int *Buffer;
int Position,Orig_Value,DesValue,Standard;
{
if ((Position==Standard-1)&&(Orig_Value<=DesValue))
  {MovePosition(Position,Orig_Value,Buffer);
   SubAssign(Buffer,Position,++Orig_Value,DesValue,Standard);
  }
else
{
  while(Orig_Value<=DesValue)
  {Buffer[Position]=Orig_Value;
   SubAssign(Buffer,Position+1,Buffer[Position]+1,Total_Num-(Standard-1-(Position+1)),Standard);
   Orig_Value++;
  }
}
}
void main(void)
{int Standard;
int *Buffer;
int i,OrigPosition=0;
fprintf(stderr,"\nHow many numbers do you want to assign\nTotal_Num=");
scanf("%d",&Total_Num);
fprintf(stderr,"\nWhich numbers do you want to assign in a team\nStandard=");
scanf("%d",&Standard);
printf("\n");
Buffer=calloc(Standard,sizeof(int));
for (i=0;i<Standard;i++)
  Buffer[i]=i+1;
SubAssign(Buffer,OrigPosition,Buffer[OrigPosition],Total_Num-(Standard-1-OrigPosition),Standard);
free(Buffer);
fprintf(stderr,"\ttimes=%d",times);
}
要从输出的数中选出几组自己需要的,怎么办?是不是要用指针?
请各位指点迷津
----------------解决方案--------------------------------------------------------
  相关解决方案