博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
字母重排
阅读量:7058 次
发布时间:2019-06-28

本文共 1408 字,大约阅读时间需要 4 分钟。

//---------------MY CODE-------------------------#include
#include
#include
using namespace std;string get(string word){ for(int i = 1; i != word.size(); ++i) { char key = word[i]; for(int j = i-1; j >= 0 && word[j] > key; --j) //升序 word[j+1] = word[j]; word[j+1] = key; } return word;}void marry(const vector
&dictionary, const string &word){ vector
::size_type i = 0; bool flag = false; for(; i != dictionary.size(); ++i) { if(get(word) == get(dictionary[i]) && word != dictionary[i]) { if(flag == true) cout << " "; cout << dictionary[i]; flag = true; } } if(flag == false) cout << ":("; cout << endl;}int main(){ vector
dictionary; cout << "Fill in the dictinory:" << endl; string word; while(cin >> word && word != "******") dictionary.push_back(word); cout << "Enter some words(Ctr+Z to end):" << endl; while(cin >> word) { marry(dictionary, word); } return 0;}

 

例子:

tarp given score refund only trap work earn course pepper part******  resco nfudre aptr sett oresuc

输出;

posted on
2012-11-13 22:55 阅读(
...) 评论(
...)

转载于:https://www.cnblogs.com/sanghai/archive/2012/11/13/2768965.html

你可能感兴趣的文章
2018.10.29-dtoj-3999-游戏(game)
查看>>
LNOI2019 游记
查看>>
php简单实现MVC
查看>>
json和jsonp的区别(转)
查看>>
轮播图
查看>>
我们为什么要当程序员?
查看>>
Bootstrap3系列:按钮组
查看>>
React笔记:组件(3)
查看>>
tomcat与jboss 01
查看>>
【记录一个问题】linux + opencv + gpu视频解码,好不容易编译通过,运行又coredump了...
查看>>
问题总结
查看>>
testNG框架,使用@BeforeClass标注的代码,执行失败不抛出异常,只提示test ignore的解决方法...
查看>>
[C++基础]020_C++0x新特性之右值引用(int&& value)
查看>>
java高并发之CountDownLatch,CyclicBarrier和join
查看>>
【简易版】IOS仿periscope自制狂赞飘桃心
查看>>
xss其他标签下的js用法总结大全
查看>>
《图像处理实例》 之 寻找图纸标注
查看>>
3的幂的和
查看>>
Maximum Value(CodeForces - 484B)
查看>>
ASP_NET Global_asax详解
查看>>