//意识到一个重要错误,一直以为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. Java的最大优势还是跨平台么?

    之前码农界有码农说Java的最大优势是跨平台,真的是这样么?其实当时网络没这么火爆的时候,确实是这样的,但现在这已然不是了. 跨平台还是Java的最大优势么? 有跨平台需求的仅仅是客户端应用,而不是服 ...

  2. Visual Studio 2012 比较好用的插件推荐

    为了高效率的开发,下面笔者推荐几款非常不错的插件,方便大家.   以上控件的安装方式是: 然后通过联网的方式下载,安装后,需要重启一下Visual Studio方可使用.

  3. centos6配置远程桌面,使用xmanager访问

    现在linux的图形界面越来越丰富,使用图形界面操作也逐渐成为使用者的一种习惯.在我们安装文件的过程中,经常会应用得到. 比如远程安装oracle,或者有多台主机.避免在不同主机间切换显示器. 1.检 ...

  4. poj 2567 Code the Tree 河南第七届省赛

    Code the Tree Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 2350   Accepted: 906 Desc ...

  5. Android之Handler

    1.Handler默认情况下与主线程处于同一线程 public class MainActivity extends Activity { private Button startButton = n ...

  6. UIActionSheet 传值

    #pragma mark - actionSheet - (void)shareOrder:(NSDictionary *)product { UIActionSheet *as = [[UIActi ...

  7. wcf使用task实现异步调用

    private async void btnGetEmployees_Click(object sender, RoutedEventArgs e) { txtInfo.Text = "Da ...

  8. java的io读取

    package gys; import java.io.BufferedReader; import java.io.File; import java.io.FileInputStream; imp ...

  9. node在安装完成后,出现node不是内部或外部命令

    node在安装完成后,查看node版本 node -v出现"node不是内部或外部命令"郁闷. 各种搜索之后,处理好了问题了. 一张图解决问题.

  10. SVN提交数据失败问题(提示 svn:MKACTIVITY ... 403 Forbidden )

    注册了淘宝svn,结果在代码提交是老是出问题,如下截图所示: 网上有常用的一种方法是: http://jingyan.baidu.com/article/67508eb4d3f2e29ccb1ce47 ...