0
点赞
收藏
分享

微信扫一扫

string(的一些用法)

闲嫌咸贤 2022-02-24 阅读 78
/************
Author Smile
sort 排序的连续性
string 可以直接相加
排成一个最大的数必然是连续排着的最大
连续排着的最大,就可以用sort来实现
只要比较两个相加即可 
string 可以申明数组 
https://vjudge.csgrandeur.cn/contest/477345#problem/B
************/
#include <iostream>
#include <algorithm>
using namespace std;
const int N = 20;
int n;
string a[N];

bool comp(string a, string b)
{
	return a + b > b + a;
}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0), cout.tie(0);
	cin >> n;
	for (int i = 1; i <= n; ++i)
	{
		cin >> a[i];
	}
	sort(a + 1, a + 1 + n, comp);
	for (int i = 1; i <= n; ++i)
	{
		cout << a[i];
	} 
	return 0;
} 
举报

相关推荐

0 条评论