4 生成全排列

4 生成全排列

作者: 赵晓鹏时间限制: 1S章节: 递归与分治

 

输入范例 :

输出范例 :

Perm1(1):123
Perm1(2):123
Perm1(2):213
Perm1(2):321
Perm1(3):123
Perm1(3):132
Perm1(3):213
Perm1(3):231
Perm1(3):321
Perm1(3):312

Online Judge 1.0

 

#include<iostream>
using namespace std;
void perm1() {cout << "Perm1(1):" << 1234 << endl;
}void perm2() {cout << "Perm1(2):" << 1234 << endl;cout << "Perm1(2):" << 2134 << endl;cout << "Perm1(2):" << 3214 << endl;cout << "Perm1(2):" << 4231 << endl;
}
void perm3() {cout << "Perm1(3):" << 1234 << endl;cout << "Perm1(3):" << 1324 << endl;cout << "Perm1(3):" << 1432 << endl;cout << "Perm1(3):" << 2134 << endl;cout << "Perm1(3):" << 2314 << endl;cout << "Perm1(3):" << 2431 << endl;cout << "Perm1(3):" << 3214 << endl;cout << "Perm1(3):" << 3124 << endl;cout << "Perm1(3):" << 3412 << endl;cout << "Perm1(3):" << 4231 << endl;cout << "Perm1(3):" << 4321 << endl;cout << "Perm1(3):" << 4132 << endl;
}
void perm4() {cout << "Perm1(4):" << 1234 << endl;cout << "Perm1(4):" << 1243 << endl;cout << "Perm1(4):" << 1324 << endl;cout << "Perm1(4):" << 1342 << endl;cout << "Perm1(4):" << 1432 << endl;cout << "Perm1(4):" << 1423 << endl;cout << "Perm1(4):" << 2134 << endl;cout << "Perm1(4):" << 2143 << endl;cout << "Perm1(4):" << 2314 << endl;cout << "Perm1(4):" << 2341 << endl;cout << "Perm1(4):" << 2431 << endl;cout << "Perm1(4):" << 2413 << endl;cout << "Perm1(4):" << 3214 << endl;cout << "Perm1(4):" << 3241 << endl;cout << "Perm1(4):" << 3124 << endl;cout << "Perm1(4):" << 3142 << endl;cout << "Perm1(4):" << 3412 << endl;cout << "Perm1(4):" << 3421 << endl;cout << "Perm1(4):" << 4231 << endl;cout << "Perm1(4):" << 4213 << endl;cout << "Perm1(4):" << 4321 << endl;cout << "Perm1(4):" << 4312 << endl;cout << "Perm1(4):" << 4132 << endl;cout << "Perm1(4):" << 4123 << endl;
}
int main() {perm1();perm2();perm3();perm4();return 0;}

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.hqwc.cn/news/18076.html

如若内容造成侵权/违法违规/事实不符,请联系编程知识网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

IP地址【图解TCP/IP(笔记十)】

文章目录 IP地址的基础知识IP地址的定义IP地址由网络和主机两部分标识组成IP地址的分类广播地址IP多播子网掩码 IPv4首部 IP地址的基础知识 在用TCP/IP通信时&#xff0c;用IP地址识别主机和路由器。为了保证正常通信&#xff0c;有必要为每个设备配置正确的IP地址。在互联网通…

短视频seo源码开发部署技术解析

短视频seo开发需要哪些技术 应用程序优化技术&#xff1a;包括应用程序的各种元素&#xff08;如标题、描述、关键字、图标等&#xff09;的优化和设置&#xff0c;以及应用程序内部链接和导航的合理布局和设置。 视频内容优化技术&#xff1a;包括视频标题、描述、标签、封面…

开发uniapp苹果app,苹果签名证书的创建方法

在uniapp云打包界面&#xff0c;打包苹果app&#xff0c;需要私钥证书p12文件&#xff0c;还需要证书profile文件和证书密码。 这两个文件到底是从什么地方获取的呢&#xff1f;答案是这两个证书需要在苹果开发者中心生成&#xff0c;下面我们这篇教程&#xff0c;将教会大家如…

图形编辑器开发:参考线吸附功能,让图形自动对齐

最近我给图形编辑器增加了参照线吸附功能&#xff0c;讲讲我的实现思路。 我正在开发的图形设计工具&#xff1a; https://github.com/F-star/suika 线上体验&#xff1a; https://blog.fstars.wang/app/suika/ 效果是被移动的图形会参考周围图形&#xff0c;自动与它们进行吸附…

基于控制屏障函数的安全关键系统二次规划(适用于ACC)(Matlab代码实现)

目录 &#x1f4a5;1 概述 &#x1f4da;2 运行结果 &#x1f389;3 参考文献 &#x1f468;‍&#x1f4bb;4 Matlab代码 &#x1f4a5;1 概述 基于控制屏障函数的安全关键系统二次规划&#xff08;适用于ACC&#xff09;是一种用于自适应巡航控制&#xff08;ACC&#x…

使用infura创建以太坊网络

创建账号 https://www.infura.io/zh 进入控制台Dashboard&#xff0c;选择CREATE API KEY 创建成功后&#xff0c;进入API KEY查看&#xff0c;使用PostMan测试 返回result即为当前区块。

如何在Microsoft Word中快速对齐名字

对齐方式决定段落边缘的外观和方向:左对齐文本、右对齐文本、居中文本或对齐文本,这些文本沿左右边距均匀对齐。例如,在左对齐(最常见的对齐方式)的段落中,段落的左边缘与左边距齐平。 在 Microsoft Word 中,还有不少的人用敲空格的方式来对齐的目的,特别是两个字的姓名…

MySQL简单查询操作

系列文章目录 前言SELECT子句SELECT后面之间跟列名DISTINCT,ALL列表达式列更名 WHERE子句WHERE子句中可以使用的查询条件比较运算特殊比较运算符BETWEEN...AND...集合查询&#xff1a;IN模糊查询&#xff1a;LIKE空值比较&#xff1a;IS NULL 多重条件查询 ORDER BY子句排序复杂…

【Java练习题汇总】《第一行代码JAVA》入门介绍篇程序基本概念篇,汇总Java练习题——基础语法:变量、数据类型、运算符、控制流... ~

Java练习题 入门介绍篇&程序基本概念篇 1️⃣ 入门介绍篇习题2️⃣ 程序基本概念篇习题 1️⃣ 入门介绍篇习题 一、填空题 Java 源程序文件的后缀是_______, Java 字节码文件的后缀名称是_______。Java 程序实现可移值性&#xff0c;依靠的是______________。Java 语言的…

springboot自动装配

一、概念&#xff1a; SpringBoot项目主启动类的main方法有一个SpringBootApplication注解&#xff0c;我们可以点进去看一下发现这个注解其实是一个复合注解&#xff0c;包含了SpringBootConfiguration、ComponentScan、EnableAutoConfiguration等注解。而SpringBoot 自动配置…

linux /var分区使用率高处理

某个数据库机器报/var分区使用率高 [roothydb2 ~]# df -h Filesystem Size Used Avail Use% Mounted on devtmpfs 95G 64K 95G 1% /dev tmpfs 95G 644M 94G 1% /dev/shm tmpfs …

记录一个heatmap.js在strict模式下的bug

ImageData的data属性只读&#xff0c;无法修改 出问题的在原始代码的490行~528行 var img this.shadowCtx.getImageData(x, y, width, height);var imgData img.data;var len imgData.length;var palette this._palette;for (var i 3; i < len; i 4) {var alpha imgD…