跳到正文

题解

p1177排序(题解)

wangAPOzhiyong约 1 分钟
原文
文章信息与版本

文章信息

发布
2024年5月29日
收录
2025年12月12日
更新
2026年10月13日
篇幅
约 1 分钟
获赞
1
题目
P1177

版本

  1. v1当前

p1177排序(题解)

真服了题解搞得太复杂了

者题只要知道long long数组能开多少这题+sort,也就算AC了

long long 大概能开20000000/2,因为int的范围是2的31次方,那么long long就要/2,如果你要定数就定100000

既然已经知道了long long的范围,还要知道sort,sort就是一个排序函数,在STL里面的函数,还要之到详细内容就自己搜,然后+输入+输出,就无了。

上代码

C++
#include<bits/stdc++.h>
using namespace std;
int main(){

	int n; 
	long long a[100000];
	cin>>n;
	for(int i=1;i<=n;i++){

		cin>>a[i];
	}
	sort(a+1,a+n+1);
	for(int i=1;i<=n;i++){

		cout<<a[i]<<" ";
	}
	}
原文