- 浏览: 36701 次
- 性别:
- 来自: 杭州
最新评论
由一道面试题改的 把数组排成最小的数
不同之处是这个是直接按字符串处理的
Sample Input:
5 32 321 3214 0229 87Sample Output:
22932132143287
#include <iostream> #include <string> #include <sstream> #include <algorithm> using namespace std; bool compare(const string& str1, const string &str2) { string s1=str1+str2; string s2=str2+str1; return s1<s2; } void ComArrayMin(int num) { string *pStrArray=new string[num]; for(int i=0; i<num; i++) { cin>>pStrArray[i]; } sort(pStrArray, pStrArray+num, compare); string str = ""; for(int i = 0; i < num; i++) { str += pStrArray[i]; } int j = 0; for ( ;j < str.length(); j++) { if (str[j] != '0') { break; } } if (j == str.length()) { str = "0"; } else { str = str.substr(j, str.length() - j); } cout<<str; cout<<endl; delete[] pStrArray; } int main() { int Num; cin>>Num; ComArrayMin(Num); return 0; }
发表评论
-
PAT1013 Battle Over Cities
2012-11-29 23:59 775Sample Input 3 2 3 1 2 1 3 ... -
PAT1003 Emergency
2012-11-29 23:46 664Sample Input 5 6 0 2 1 2 1 ... -
PAT1041 Be Unique
2012-11-23 23:43 762找出只出现过一次的数,用各种排序必然超时,需要用数组做hash ... -
PAT1042 Shuffling Machine
2012-11-23 23:42 735扑克洗牌 #include < ... -
PAT1040 Longest Symmetric String
2012-11-23 23:41 960求最长回文子串 #include < ... -
PAT1036 Boys vs Girls
2012-11-23 23:41 716Sample Input 1: 3 Joe M Mat ... -
PAT1035 Password
2012-11-23 23:40 618Sample Input 1: 3 Team0000 ... -
PAT1031 Hello World for U
2012-11-22 23:54 656Sample Input: helloworld! S ... -
PAT1029 Median
2012-11-22 23:54 655用标准库的排序全部超时,需要自己实现,另外还不能用cin co ... -
PAT1028 List Sorting
2012-11-22 23:53 810用vector最后一个用例超时了。。。 Sample ... -
PAT1027 Colors in Mars
2012-11-22 23:52 625Sample Input 15 43 71 Samp ... -
PAT1025 PAT Ranking
2012-11-22 23:51 774Sample Input: 2 5 123456789 ... -
PAT1023 Have Fun with Numbers
2012-11-21 23:55 688大数的相加 比较两个字符串中字符完全相同 Sa ... -
PAT1020 Tree Traversals
2012-11-21 23:54 654已知中序遍历 后序遍历,求层次遍历 Sample In ... -
PAT1019 General Palindromic Number
2012-11-21 23:53 539十进制转任意进制,并比较是否是回文数 Sample I ... -
PAT1037 Magic Coupon
2012-11-21 15:46 664Sample Input: 4 1 2 4 -1 ... -
PAT1024 Palindromic Number
2012-11-20 23:51 650Sample Input 1: 67 3 Sampl ... -
PAT1015 Reversible Primes
2012-11-19 23:51 771十进制转任意进制 假设十进制数为number,转 ... -
PAT1012 The Best Rank
2012-11-19 23:50 927四门功课,输出排名最高的是哪个 Sample Inpu ... -
PAT1011 World Cup Betting
2012-11-19 23:50 536Sample Input 1.1 2.5 1.7 1.2 ...
相关推荐
Please read the following terms and conditions carefully because they will apply to Your use of both the unregistered and registered versions of the software program Recover4all(tm) Professional and ...
word recover word recover word recover word recover v
can recover files that were removed from the recycle bin and also directly deleted files that haven`t been in the recycle bin. Please note that it cannot be told in advance, if a specific file can be ...
word recover word recover word recover word recover word recover
上尚城配电(一期)_recover_recover_recover.dwg11111111111111111111111111111111111111111111111111111111
Nuclear Coffee Recover Passwords 是一款用于备份和恢复计算机系统中安装的软件产品密匙的工具。 失去了微软视窗,微软Office,Nero的,和Adobe或Acronis产品你的产品密钥?或者,也许你的硬盘驱动器崩溃?也许你是...
Recover_Truncate_data.recover_table(tgtowner, tgttable, tgtowner, rectab, tgtowner, rsttab, datadir, datadir, recfile,datadir, copyfile, blksz); end; 第七步:查看输出内容和构造表名: 15:32:...
7260 recover
一款绿色版本 无毒 反应快的数据恢复工具,
存储过程包Fy_Recover_Data 利用Oracle表扫描机制、数据嫁接机制恢复TRUNCATE或者损坏数据的工具包
recover 是一款免安装的数据恢复软件 简单实用·
Recover4all® is an easy to use data recovery software that lets you recover (undelete) files that were accidently deleted under Windows. It does not matter, if the files were removed from the recycle...
The Concept of Recoverable Robustness,Linear Programming Recover
软件名称:Recover4All Professional 最新版本:2.09 软件授权:汉化破解版本 使用平台:Win95/98/NT/2000/XP 软件简介: 每个人一定都有曾不小心误删文件与目录的经历,要恢复误删的文件,通常是十分 困难的。...
RecoverMyFiles Recover My Files可以恢复由于冒失删除的文档,甚至是磁盘格式化后的文件 恢复工具,它可以自定义搜索的文件夹、文件类型,以提高搜索速度及准确性 节约时间。在搜索过程中,提供了大量的信息,包括...
数据恢复工具 RecoverMyFiles 破解版
这款RAR密码破解软件RAR与上面那个软件有相似之处。同时能进行多个RAR压缩文件的破解——双开就行。可以自己设置爆破的字符集(支持非英文字符)、中断续破。...还提供了估算破解所需要的时间。运行平台与上一样。...
是相当困难的,不妨先试试 Recover 4 all 看看,它能将刚刚所删除的档案找 出来,但必须在 Windows 下所删除的文件,它才能找出并挽救回来。该版本可 以运行于 Win9x/Me/NT/2000/XP 等操作系统下,帮助你在这些操作...
The user can’t choose the place they recover the file to and can’t see the content of a file in Cycle Bin. HE6—Good Feature The shortcut mean of the Cycle Bin have similar style with other windows...
利用先序,中序遍历恢复二叉树 ,用兴趣的朋友可以看一下