PAT Advanced Level 1038
来源:互联网 发布:excel如何下拉选择数据 编辑:程序博客网 时间:2024/05/21 08:01
题目地址:http://pat.zju.edu.cn/contests/pat-a-practise/1038
思路分析:主要在于确立排序规则
代码如下:
#include <iostream>#include <cstdio>#include <string>#include <algorithm>#include <vector>using namespace std;vector<string> v;int cmp(string s1,string s2){ string a=s1+s2; string b=s2+s1; return a.compare(b)<0;}int main(){ freopen("C:\\Users\\Devon\\Desktop\\input.txt","r",stdin); int n; cin>>n; for(int i=0;i<n;i++){ string temp; cin>>temp; v.push_back(temp); }; sort(v.begin(),v.end(),cmp); string result=""; for(int i=0;i<n;i++) result+=v[i]; int i; for(i=0;i<result.length();i++) if(result[i]!='0') break; result=result.substr(i); if(result.length()==0) cout<<0<<endl; else cout<<result<<endl; return 0;}
0 0
- PAT Advanced Level 1038
- PAT Advanced Level 1077
- PAT Advanced Level 1078
- PAT Advanced Level 1079
- PAT Advanced Level 1080
- PAT Advanced Level 1010
- PAT Advanced Level 1016
- PAT Advanced Level 1018
- PAT Advanced Level 1039
- PAT Advanced Level 1060
- PAT Advanced Level 1026
- PAT Advanced Level 1029
- PAT Advanced Level 1030
- PAT Advanced Level 1033
- PAT Advanced Level 1034
- PAT Advanced Level 1045
- PAT Advanced Level 1049
- PAT Advanced Level 1051
- java二维码生成与解析代码实现
- 理想与现实
- 压缩与备份
- jquery同时验证邮箱和手机号吗
- Linux创建普通文件 vim
- PAT Advanced Level 1038
- python web应用搭建
- 优化IMPDP/EXPDP
- JasperReports+iReport在eclipse中的使用
- 利用sqoop将hive数据导入导出数据到mysql
- C#下文本框的建议提示控件
- vim编辑器的使用
- Java基础回顾_二维数组计算班级学生成绩_简单
- 判断输入的ip字符串格式的合法性