询问一个输出全组合算法的时间复杂度

xxMix xxMix 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
询问一个输出全组合算法的时间复杂度,最好能说明一下怎么得来的,谢谢~~



#include <iostream>
#include <conio.h>
using namespace std;

bool L3( unsigned int &end, unsigned int staticStart, unsigned int &staticEnd ){
//终止判断
if( staticEnd >= end ){
return false;
}
unsigned int i = 0;
unsigned int j = 0;
for( i=staticEnd+1; i<=end; i++ ){
//1.输出Static Head
for( j=staticStart; j<=staticEnd; j++ ){
cout << j;
}
//2.输出变化值
cout << i << endl;
}
staticEnd++;
return true;
}

bool L2( unsigned int &end, unsigned int n ){
if( n > end ){
return false;
}
cout << n << endl;
unsigned int i = 0;
unsigned int iend = end - i;
unsigned int staticEnd = n;
while( L3( end, n, staticEnd ) ){
;
}
return true;
}

bool L1( unsigned int &end ){
if( end<1 ){
return false;
}
unsigned int i = 0;
for( i=1; i<=end; i++ ){
L2( end, i );
}
return true;
}

int main( void ){
unsigned int i = 0;
for( i=1; i<=10 ;i++ ){
system( "CLS" );
cout << "【" << i << "】的全组合数:" << endl;
cout << "--------------" << endl;
L1( i );
cout << "--------------" << endl;
cout << "按任意键继续..." << endl;
_getch( );
}
cout << "END" << endl;
_getch( );
return 1;
}
...全文

相关推荐

评论 6
收藏 已收藏
分享
返回顶部
xxMix
数据结构与算法 33,026 成员 35,334 内容