字符串递规问题.cpp

来自「这是一些c++例程」· C++ 代码 · 共 33 行

CPP
33
字号
// 字符串递规问题.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include<stdlib.h>
#include<iostream.h>
#include<string.h>

#define SIZE 10 		/*临时数组的大小,其值一定要大于N */

void Full(char *p,int n,char *s,int m)
{
	if (n==0) 
	{
		s[m]='\0';
		cout<<s<<" ";
	}
	else
		for (int i=0;i < strlen(p);i++)
		{
			s[m]=p[i];
			Full(p,n-1,s,m+1);			//函数的递归调用
		}
}

void main()
{
	char s[SIZE];
	char *p="abc";
	int m=6;
	Full("abc",m,s,0);
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?