#include <stdio.h>
#include <stdbool.h>

void PrintAll(int a[], int nBegin, int nEnd, int nCount, char* szPre){
    if(nCount==1){
        for(int i=nBegin; i<=nEnd; i++){
            printf("%s%d ", szPre, a[i] );
        }
        printf("\n");
    }else{
        for(int i=nBegin; i<=nEnd-nCount+1; i++){
            char szBuf[10]= {0};
            sprintf(szBuf, "%s%d", szPre,a[i] );
            PrintAll(a, i+1, nEnd, nCount-1, szBuf);
        }
    }
}

int main(){
    int a[] = {1,2,3,4,5,6};
    PrintAll(a, 0, 5, 3, "");
    return 1;
}

  

相关文章:

  • 2022-12-23
  • 2021-06-21
  • 2021-12-28
  • 2022-12-23
  • 2021-10-28
  • 2022-12-23
  • 2022-12-23
  • 2021-05-26
猜你喜欢
  • 2021-10-10
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-07-24
  • 2022-12-23
相关资源
相似解决方案