一.考概念:
字典序:通常用于描述字符串或其他数据的排序方式,类似于字典中单词的排列顺序。
解决方法:sort()函数
#include <bits/stdc++.h>
using namespace std;
int Cmp(const string &s1,const string &s2)//字符串的比较
{
//比较函数写const;
return s1+s2<s2+s1;
}
int main() {
int N;
cin >> N;
vector<string> a(N);
//vector可以传入多种类型的数组,后面跟括号初始化
for (int i = 0; i < N; i++) {
cin >> a[i];
}
sort(a.begin(),a.end(),Cmp);
//后面跟比较函数不用括号
for (int i=0;i<N;i++) {
cout<<a[i];
}
return 0;
}
二.填空题考数据过大溢出
用python直接print(...)
python的整数无上限,但浮点数有
print(pow(2,2023)%1000)
#幂函数用pow
print(12345678901234567890123456789012345678901234567890%2023)