//意识到一个重要错误,一直以为atoi,itoa是windows独有的,linux下不可用,直到刚刚。。。

//string+=比strcat好用多了,字符比较也方便的多,但是用scanf读入string,好麻烦。。。cin读入老是出错不晓得为什么,cin对于空格和换行符的处理还不是很清楚,c++没有系统学习,半c半++中。。。。,刷完一定找机会吧c++系统一下

//突然想起来第一次刷时,居然一个一个字符的比较。。。。。哭晕

//该方法来自晴神宝典

#include<cstdio>
#include<vector>
#include<string>
#include<algorithm>
using namespace std;
typedef struct
{
char str[10];
}node;
vector<node>list;
bool cmp(node a,node b)
{
char s1[20],s2[20];
strcpy(s1,a.str);strcpy(s2,b.str);
strcat(s1,b.str);strcat(s2,a.str);
return strcmp(s1,s2)<0;
}
int main()
{
freopen("input.txt","r",stdin);
int i,n;
long int s;
while(scanf("%d",&n)!=EOF)
{
for(i=0;i<n;i++)
{
node tmp;
scanf("%s",tmp.str);
s=atoi(tmp.str);
if(s!=0)list.push_back(tmp);
}
if(list.size()==0)printf("0");
else
{
sort(list.begin(),list.end(),cmp);
s=atoi(list[0].str);
printf("%ld",s);
for(i=1;i<list.size();i++)printf("%s",list[i].str);
}
printf("\n");
}
return 0;
}

PAT1038. Recover the Smallest Number的更多相关文章

  1. pat1038. Recover the Smallest Number (30)

    1038. Recover the Smallest Number (30) 时间限制 400 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHE ...

  2. 把数组排成最小的数/1038. Recover the Smallest Number

    题目描述 输入一个正整数数组,把数组里所有数字拼接起来排成一个数,打印能拼接出的所有数字中最小的一个.例如输入数组{3,32,321},则打印出这三个数字能排成的最小数字为321323.   Give ...

  3. 1038. Recover the Smallest Number (30) - 字符串排序

    题目例如以下: Given a collection of number segments, you are supposed to recover the smallest number from ...

  4. A1038. Recover the Smallest Number

    Given a collection of number segments, you are supposed to recover the smallest number from them. Fo ...

  5. PAT甲1038 Recover the smallest number

    1038 Recover the Smallest Number (30 分) Given a collection of number segments, you are supposed to r ...

  6. 1038 Recover the Smallest Number (30 分)

    1038 Recover the Smallest Number (30 分) Given a collection of number segments, you are supposed to r ...

  7. 1038. Recover the Smallest Number (30)

    题目链接:http://www.patest.cn/contests/pat-a-practise/1038 题目: 1038. Recover the Smallest Number (30) 时间 ...

  8. PAT 1038 Recover the Smallest Number[dp][难]

    1038 Recover the Smallest Number (30 分) Given a collection of number segments, you are supposed to r ...

  9. PAT 甲级 1038 Recover the Smallest Number

    https://pintia.cn/problem-sets/994805342720868352/problems/994805449625288704 Given a collection of ...

随机推荐

  1. IGS_学习笔记07_IREP通过页面测试客户化Web Service调用(案例)

    20150819 Created By BaoXinjian

  2. YUV422/YUV420播放

    YUV播放器,directX,VS2008 MFC完成  CSDN下载 http://download.csdn.net/detail/xjt1988xjt/2386621#comment 默认是播放 ...

  3. Apache Thrift学习之二(基础及原理)

    Apache Thrift 是 Facebook 实现的一种高效的.支持多种编程语言的远程服务调用的框架.本文将从 Java 开发人员角度详细介绍 Apache Thrift 的架构.开发和部署,并且 ...

  4. CSS如何实现图片上下垂直居中

    方法一: 使用margin方式,使图片在div中上下垂直居中.margin-top值的计算方式是:div的高度/2-图片高度/2. 代码实例如下: <!DOCTYPE html><h ...

  5. 全文检索引擎Solr系列—–全文检索基本原理

    场景:小时候我们都使用过新华字典,妈妈叫你翻开第38页,找到“坑爹”所在的位置,此时你会怎么查呢?毫无疑问,你的眼睛会从38页的第一个字开始从头至尾地扫描,直到找到“坑爹”二字为止.这种搜索方法叫做顺 ...

  6. tony_linux下网站压力测试工具webbench

    webbench最多可以模拟3万个并发连接去测试网站的负载能力,个人感觉要比Apache自带的ab压力测试工具好,安装使用也特别方便. 1.适用系统:Linux 2.编译安装:wget http:// ...

  7. JAVA中抽象类的一些总结

    抽象类和普通类一样,有构造函数.抽象类中有一些属性,可以利用构造方法对属性进行初始化.子类对象实例化的时候先执行抽象类的构造,再执行子类构造. 抽象类不能用final声明.因为抽象类必须有子类继承,所 ...

  8. (DP)MaxSubArr

    public static int MSA(int[] ar) { int[] arr = new int[ar.length]; int msa = 0; arr[0] = ar[0]; for ( ...

  9. Android--创建进度框ProgressDialog

    1.布局文件progress_dialog_activity.xml <?xml version="1.0" encoding="utf-8"?> ...

  10. framMaker、Velocity模版引擎

    1.一种模板文件,可以自动加载数据到模板里面展现. 类似:Velocity 2.使用场景 1.web开发模式 WEB-INF/view/vm 在互联网公司的开发都是基于vm的开发,其次就是使用JS的框 ...