1038. Recover the Smallest Number
来源:互联网 发布:原知宏大野智 编辑:程序博客网 时间:2024/05/18 00:10
比较喜欢这种题,代码不长,但是有意思。
从别人那学习到的
#include <iostream>#include <string>#include <algorithm>#include <stdio.h>using namespace std;bool compare(const string &str1, const string &str2){ return str1+str2 < str2+str1;}int main(){ int n; string *nums; cin >> n; nums = new string[n]; for(int i = 0; i < n; i++) cin >> nums[i]; sort(nums, nums+n, compare); string output=""; for(int i = 0; i < n; i++) output += nums[i]; int i; for(i = 0; i < output.length()-1; i++) { if(output[i] != '0') break; } output = output.substr(i); cout << output; return 0;}
0 0
- 1038. Recover the Smallest Number
- 1038. Recover the Smallest Number
- 1038. Recover the Smallest Number
- 1038. Recover the Smallest Number
- 1038. Recover the Smallest Number
- 1038. Recover the Smallest Number
- 1038. Recover the Smallest Number
- 1038. Recover the Smallest Number (30)
- 1038. Recover the Smallest Number (30)-PAT
- 1038. Recover the Smallest Number (30)
- 1038. Recover the Smallest Number (30)
- PAT 1038. Recover the Smallest Number
- PAT 1038. Recover the Smallest Number
- 1038. Recover the Smallest Number (30)
- PAT 1038. Recover the Smallest Number
- 1038. Recover the Smallest Number (30)
- 1038. Recover the Smallest Number (30)
- 1038. Recover the Smallest Number (30)
- codesmith 三层架构代码生成
- sql
- CSDN文章发布了显示问题
- CSAPP Cache实验
- 【OpenCV】有关内存释放 总结
- 1038. Recover the Smallest Number
- 欢迎使用CSDN-markdown编辑器
- div层调整z-index属性无效原因分析及解决方法
- Spring整合Struts 2,以及Spring中Bean的作用域问题
- Python 客制化类的创建过程
- 将用户在jsp表单输入的信息赋给JavaBean
- 向量积(叉积)及其计算
- Jquery--text()与html()方法的区别
- Android Studio 快捷键