#include "stdio.h"
#include "string.h"
#include "stdlib.h"
#include "math.h"
#include <iostream>
using namespace std;
void printout(char* chfirst,char* chend, int m, int n);
int main(void)
{
char ch[100];
char chfirst[100] = {'\0'};
int sh;
cin>>ch>>sh;
int len1=strlen(ch);
if (len1<sh || sh==0)
{
cout<<"ERROR";
return -1;
}
printout(chfirst, ch, sh, len1);
cin>>sh;
}
void printout(char* chfirst,char* chend, int m, int n)
{
if(m == n)
cout<<chfirst<<chend<<" ";
else if(m == 0)
{
cout<<chfirst<<" ";
}
else
{
int len = strlen(chfirst);
chfirst[len] = chend[0];
chfirst[len+1] = '\0';
chend++;
printout(chfirst, chend, m-1, n-1);
chfirst[len] = '\0';
printout(chfirst, chend, m, n-1);
}
}
20150915华为软件笔试题-从m个不同字母中任取n个字目的组合
最新推荐文章于 2025-02-16 15:49:17 发布