1038. Recover the Smallest Number (30)
来源:互联网 发布:飞机水上迫降 知乎 编辑:程序博客网 时间:2024/06/08 06:34
经典面试题,需要排序,关键是知道 a+b<b+a
#include <iostream>#include <stdio.h>#include <string.h>#include <vector>#include <map>#include <stack>#include <queue>#include <algorithm>#include <set>using namespace std;bool cmp(string a ,string b){ return a+b<b+a;}int n;string tmp,ans;vector<string> num;int main(){ cin>>n; while(n--){ cin>>tmp; num.push_back(tmp); } sort(num.begin(),num.end(),cmp); for(int i=0;i<num.size();i++){ ans+=num[i]; } bool flag=false; //cout<<ans<<endl; for(int i=0;i<ans.size();i++){ if(ans[i]=='0'&&!flag) continue; else flag=1,printf("%c",ans[i]); } if(!flag) printf("0\n"); return 0;}
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)
- SDUT 1298 活动选择
- ArcGIS,Plsql,Navicat连接Oracle的配置比较
- 十一、数据处理函数
- codeforces 305B. Continued Fractions(数学)
- 蓝桥杯省赛小结
- 1038. Recover the Smallest Number (30)
- python的数据爬取问题
- 正经的树链剖分
- OpenLayers+天地图+Geoserver+WMS图层服务
- 搭建Struts2步骤
- SVM浅析
- HITCTF PWN300--dynelf
- 懂商业的技术合伙人(8):最常见的11种云服务
- WebView与js交互(2)