文章

28

粉丝

0

获赞

60

访问

1.6k

头像
遍历链表 题解:摸你
P1405 华中科技大学
发布于2026年3月20日 22:03
阅读数 6

#include<bits/stdc++.h>

using namespace std;

int main(){

	int n;	
	while(cin>>n){
	vector<int> lst;
	
	while(n--){
	int temp;
		cin>>temp;
	lst.push_back(temp);
	}
	
	sort(lst.begin(),lst.end());  //默认升序,如果要降序可以写一个bool cmp(int a,int b)函数,
                                  //然后return a>b; ,放到sort函数的第三位.
	
	for(auto it:lst) cout<<it<<" ";
	}
return 0;
}

 

登录查看完整内容


登录后发布评论

暂无评论,来抢沙发