PAT A1038 recover the smallest number (30)
来源:互联网 发布:最牛的请假条淘宝 编辑:程序博客网 时间:2024/05/29 21:28
#include<cstdio>
#include<algorithm>
#include<string>
#include<cstring>
#include<iostream>
using namespace std;
bool cmp(string a,string b){
return (a+b)<(b+a);
}
int main(){
string str[10010];
int n,i;
cin>>n;
for(i=0;i<n;i++){
cin>>str[i];
}
sort(str,str+n,cmp);
i=0;
while(str[i][0]=='0'){
str[i].erase(0,1);
if(str[i].size()==0){
i++;
n--;
}
}
if(n==0) printf("0");
for(i=0;i<n;i++){
cout<<str[i];
}
system("pause");
return 0;
}
#include<algorithm>
#include<string>
#include<cstring>
#include<iostream>
using namespace std;
bool cmp(string a,string b){
return (a+b)<(b+a);
}
int main(){
string str[10010];
int n,i;
cin>>n;
for(i=0;i<n;i++){
cin>>str[i];
}
sort(str,str+n,cmp);
i=0;
while(str[i][0]=='0'){
str[i].erase(0,1);
if(str[i].size()==0){
i++;
n--;
}
}
if(n==0) printf("0");
for(i=0;i<n;i++){
cout<<str[i];
}
system("pause");
return 0;
}
0 0
- pat-a1038. Recover the Smallest Number (30)
- PAT A1038 recover the smallest number (30)
- PAT甲级练习题A1038. Recover the Smallest Number (30)
- A1038. Recover the Smallest Number (30)
- A1038. Recover the Smallest Number (30)
- 贪心算法--PAT.A1038.Recover the Smallest Number
- PAT A1038 Recover the Smallest Number 算法问题和关于'0'和0的小错误
- 1038. Recover the Smallest Number (30)-PAT
- PAT 1038. Recover the Smallest Number (30)
- 【PAT】1038. Recover the Smallest Number (30)
- [pat]1038. Recover the Smallest Number (30)
- pat 1038. Recover the Smallest Number (30)
- PAT 1049Recover the Smallest Number (30)
- PAT 1038. Recover the Smallest Number (30)
- PAT A 1038. Recover the Smallest Number (30)
- PAT (Advanced) 1038. Recover the Smallest Number (30)
- PAT (Advanced Level) Practise 1038 Recover the Smallest Number (30)
- PAT(A) - 1038. Recover the Smallest Number (30)
- OAuth2.0协议 - 介绍
- Java IO流学习总结
- Servlet是线程安全的吗?
- 个人记录-LeetCode 90. Subsets II
- 计算机网络课程第一节课知识点
- PAT A1038 recover the smallest number (30)
- HDU 1087 Super Jumping! Jumping! Jumping! (基础dp)
- 极客学院----H5的相关笔记----css基础(二)
- omnet Program "g++" not found in PATH Program "gcc" not found in PATH
- HDU 1695 GCD (容斥原理)
- 设计模式学习之访问者模式
- 287. Find the Duplicate Number
- 微信小程序之基于canvas绘制高铁线路图
- 20170220找女朋友之路思考总结