1038. Recover the Smallest Number (30)
来源:互联网 发布:crm源码怎么安装 编辑:程序博客网 时间:2024/06/05 15:35
注意除去前面零的几种情况
#include<iostream>#include<algorithm>#include<vector>#include<map> #include<string>#include<set>using namespace std;vector<string> s;bool comp(string a, string b){string s1 = a + b;string s2 = b + a;if(s1 < s2) return true;else return false;}int main(){int n;cin>>n;for(int i = 0; i < n; i++){string temp;cin>>temp;s.push_back(temp);} sort(s.begin(),s.end(),comp);bool beginzero = true;for(int i = 0; i < n; i++){int j = 0; while(j < s[i].size()){ if(s[i][j] != '0' || beginzero == false){ printf("%c",s[i][j]); beginzero = false; } j++; }}if(beginzero == true) cout<<0;//都是零 return 0;}
1、样例的情况,只要考虑首串前面部分元素的零问题
2、可能存在一个串或多个串元素都是零
3、所有串所有元素都是零,输出结果应为“0”,序号2的两分点就是考查这个
0 0
- 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)
- 1038. Recover the Smallest Number (30)
- 1038. Recover the Smallest Number (30)
- 1038. Recover the Smallest Number (30)
- 1038. Recover the Smallest Number (30)
- 1038. Recover the Smallest Number (30)
- 1038. Recover the Smallest Number (30)
- 1038. Recover the Smallest Number (30)
- 1038. Recover the Smallest Number (30)
- 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 (30)
- 1038. Recover the Smallest Number (30)
- 【长篇高能】ReactiveCocoa 和 MVVM 入门
- codevs天梯 递归第一次 水题
- 敏捷开发流程
- ORA-12012: error on auto execute of job “SYS”.”BSLN_MAINTAIN_STATS_JOB”
- codevs天梯 3n+1问题 暴力水题
- 1038. Recover the Smallest Number (30)
- Educational Codeforces Round 13 D. Iterated Linear Function 逆元+公式+费马小定理
- 稀疏点云的重建研究
- [leetcode]--80. Remove Duplicates from Sorted Array II
- 电平转换电路设计
- PHP-封装函数练习
- 字幕文件批量重命名脚本 —— Linux
- Spring Mvc + Spring + Mybatis3 搭建Web工程详解
- HTML <strong> 和 <b>