33,311
社区成员
发帖
与我相关
我的任务
分享
#include "stdafx.h"
#include <stdio.h>
#define N 4
void fun(char * str, bool *bmap, int n)
{
if( n == N - 1 )
{
printf("{ ");
for (int j = 0; j < N -1; j++)
{
if (bmap[j])
{
printf("%c,",str[j]);
}
}
printf("\b }\n");
return;
}
bmap[n] = 0;
fun(str, bmap, n + 1);
bmap[n] = 1;
fun(str, bmap, n + 1);
}
void main()
{
char str[N] = "1d8";
bool bmap[N] = {0};
fun(str, bmap, 0);
}
#include "stdafx.h"
#define maxsize 4
void select(char a[],int n, int size)
{ int i;
if(n==maxsize)
{ printf("{");
for(i=0;i<size;i++)
{ printf("%2c",a[i]);
}
printf("}");
printf("\n");
}
else
{ select(a,n+1,size);
a[size++]='a'-1+n;
select(a,n+1,size);
size--;
}
}
int _tmain(int argc, _TCHAR* argv[])
{ char a[maxsize]={0};
int size=0;
select(a,1,size);
return 0;
}