题解 | #最后k个元素#

最后k个元素

https://www.nowcoder.com/practice/9e497c068b8a4f53b0f0576f89ff4ebe

#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,k;
	vector<int>a;
	// write your code here......
      cin>>n>>k;
	  int temp;
	  for(int i=  0;i<n;i++){
		  cin>>temp;
		  a.push_back(temp);
	  }
      auto s = a.rbegin();
	  for(int i = 0;i<k;i++){
		  cout<<*s<<' ';
		  s++;
	  }
	return 0;
}

全部评论

相关推荐

投递拼多多等公司10个岗位 Java求职圈
点赞 评论 收藏
转发
美团 客服平台 薪资应该是后端算高的了,我们姑且称为nk了,给3w签字费
点赞 评论 收藏
转发
点赞 收藏 评论
分享
牛客网
牛客企业服务