UVA - 10098 Generating Fast (全排列)

本文介绍了一种使用标准模板库(STL)中的sort和next_permutation函数来高效生成字符串所有升序排列的方法。通过示例代码展示了如何读取多个字符串,并为每个字符串生成并输出其所有不重复的排列。
Generating Fast, Sorted Permutation

Input: Standard Input

Output: Standard Output

 

Generating permutation has always been an important problem in computer science. In this problem you will have to generate the permutation of a given string in ascending order.  Remember that your algorithm must be efficient.


Input

The first line of the input contains an integer n, which indicates how many strings to follow. The next n lines contain n strings. Strings will only contain alpha numerals and never contain any space. The maximum length of the string is 10.

 
Output

For each input string print all the permutations possible in ascending order. Not that the strings should be treated, as case sensitive strings and no permutation should be repeated. A blank line should follow each output set.

 

Sample Input

3
ab
abc
bca

 

Sample Output

ab
ba

abc
acb
bac
bca
cab
cba

abc
acb
bac
bca
cab

cba


解析:生成一个字符串的全排列,直接调用STL就可以轻松解决。


#include <iostream>
#include <stdio.h>
#include <string>
#include <algorithm>
using namespace std;

int main() {
	int n;
	string str;
	while( cin >> n) {
		for(int i = 0; i < n; i++){
			cin >> str;
			sort(str.begin(),str.end());
			do{
				cout << str << endl;
			}
			while( next_permutation(str.begin(),str.end()) );
			cout << endl;
		}
	}
	return 0;
}


<think> 我们正在讨论的是在编译一个使用PCL的项目时出现的CMake输出信息。用户给出的信息是: 'Configuring done -- Generating done -- Build files have been written to: /home/wzz/shenlan/slambook/ch5/joinMap/build' 这个信息是CMake在配置和生成构建系统后输出的标准信息,表明CMake已经成功完成了配置和生成步骤,并已将构建文件(如Makefile或Ninja构建文件)写入指定的构建目录(这里是`/home/wzz/shenlan/slambook/ch5/joinMap/build`)。 接下来,用户需要在这个构建目录下运行构建命令(比如`make`)来编译项目。 然而,用户的问题背景是在安装PCL库的过程中。注意,这里用户可能混淆了安装PCL库和编译使用PCL的项目这两个过程。从上下文看,用户似乎是在编译一个使用PCL的项目(如ORB-SLAM2的稠密点云显示部分)时遇到了问题。 根据引用[1]的内容,ORB-SLAM2的ROS部分需要修改CMakeLists.txt来包含PCL库。用户已经按照指引添加了PCL相关的配置。 现在,用户看到了CMake成功配置和生成构建文件的信息,这通常意味着CMake已经找到了PCL库,并且配置没有问题。 但是,用户可能担心这个信息是否表示PCL安装成功?实际上,这个信息只表示当前项目(joinMap)的CMake配置成功,并不直接表示PCL库安装成功。PCL库的安装应该已经通过之前的步骤(如apt安装或源码安装)完成。 因此,我们需要向用户解释: 1. 这个信息的含义:CMake成功为项目生成了构建文件。 2. 接下来用户应该进入构建目录并运行构建命令(如`make`)来编译项目。 3. 如果之前已经正确安装了PCL库,那么在编译项目时应该可以成功链接PCL。 如果用户在后续编译过程中出现关于PCL的错误,那么可能是PCL安装不完整,或者CMakeLists.txt中配置PCL的方式有问题。 根据引用[2][3],如果用户在安装PCL时遇到问题(如无法定位包),可能需要添加PPA源或者换源。但根据用户当前的信息,CMake已经成功运行,所以暂时不需要这一步。 另外,引用[4]提到了更新源时出现404错误,这可能是由于PPA源不存在于当前系统版本的仓库中。但同样,用户当前并未遇到更新错误,所以这个引用只是作为背景。 因此,回答的重点是解释CMake的输出信息,并指导用户进行下一步的编译。 最后,生成相关问题。 </think> ### CMake 输出信息解析 您看到的 `Configuring done -- Generating done -- Build files have been written to: /home/wzz/.../build` 是 CMake **成功完成配置** 的标准输出,表明: 1. **配置阶段完成 (Configuring done)** - CMake 已检测到系统环境(包括编译器、依赖库等) - 已成功定位 PCL 库(若未找到会报错) - 验证了 CMakeLists.txt 中的配置有效性[^1] 2. **生成阶段完成 (Generating done)** - 已生成构建系统文件(如 Makefile 或 Ninja 文件) - 生成位置:`/home/wzz/shenlan/slambook/ch5/joinMap/build` 3. **后续操作指引** 进入该目录执行编译: ```bash cd /home/wzz/shenlan/slambook/ch5/joinMap/build make -j4 # 启动编译(数字根据CPU核心数调整) ``` --- ### 完整工作流程说明 | 阶段 | 命令 | 输出标志 | 含义 | |------|------|----------|------| | 配置 | `cmake ..` | `Configuring done` | PCL 等依赖验证通过 | | 生成 | (同上) | `Generating done` | 构建文件就绪 | | 编译 | `make` | `[100%] Built target ...` | 项目编译完成 | --- ### 常见问题排查 若后续编译失败,需检查: 1. **PCL 版本兼容性** 在 CMakeLists.txt 中确认版本要求: ```cmake find_package(PCL 1.9.1 REQUIRED) # 检查此版本是否与安装一致[^1] ``` - 查看已安装版本:`pcl-config --version` 2. **头文件/库路径** 若出现 `undefined reference` 错误,需显式链接模块: ```bash # 示例:链接 common 和 io 模块 target_link_libraries(your_target pcl_common pcl_io) ``` 3. **环境冲突** 若同时安装 ROS 的 PCL,需在 CMakeLists.txt 添加: ```cmake set(PCL_DIR "/opt/ros/noetic/share/pcl-1.10") # 指定路径优先级 ``` --- ### 验证 PCL 功能 编译成功后运行: ```bash # 在 build 目录执行 ./joinMap # 或您的可执行文件名 ``` ✅ 正常显示点云即表示 PCL 集成成功 ---
评论 1
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值