news 2026/5/12 5:06:57

2025年华中科技大学计算机考研复试机试真题(附 AC 代码 + 解题思路)

作者头像

张小明

前端开发工程师

1.2k 24
文章封面图
2025年华中科技大学计算机考研复试机试真题(附 AC 代码 + 解题思路)

2025年华中科技大学计算机考研复试机试真题

2025年华中科技大学计算机考研复试上机真题

历年华中科技大学计算机考研复试上机真题

历年华中科技大学计算机考研复试机试真题

更多学校题目开源地址:https://gitcode.com/verticallimit1/noobdream

N 诺 DreamJudge 题库:输入 “学校名称” 即可筛选该校历年机试真题,题目均在考纲范围内,按难度自动排序。还可搭配《计算机考研机试攻略》刷题,书中题目可通过题号直接在题库中查找。

排序去重

题目描述

Time Limit: 1000 ms
Memory Limit: 256 mb

输入一个长度为n的数组,先将其进行排序输出,然后对排序后的结果去重再次输出

输入输出格式
输入描述:

如题

输出描述:

如题

输入输出样例
输入样例#:
6 3 2 3 6 5 6
输出样例#:
2 3 3 5 6 6 2 3 5 6

代码一

  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. int main(){
  4. int n;
  5. cin>>n;
  6. vector<int>nums(n);
  7. for(int i=0;i<n;i++){
  8. cin>>nums[i];
  9. }
  10. sort(nums.begin(),nums.end());
  11. for(int i=0;i<n;i++){
  12. cout<<nums[i]<<" ";
  13. }
  14. cout<<endl;
  15. cout<<nums[0]<<" ";
  16. for(int i=1;i<n;i++){
  17. if(nums[i]==nums[i-1]){
  18. continue;
  19. }
  20. cout<<nums[i]<<" ";
  21. }
  22. return 0;
  23. }

代码二

  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. #define ll long long
  4. const int maxn = 100005;
  5. int main() {
  6. int n;
  7. cin >> n;
  8. vector<int> arr(n);
  9. set<int> st;
  10. for (int i = 0; i < n; i++){
  11. int temp;
  12. cin >> temp;
  13. arr[i] = temp;
  14. st.insert(temp);
  15. }
  16. sort(arr.begin(), arr.end());
  17. for (int i = 0; i < n; i++){
  18. cout << arr[i] << ' ';
  19. }
  20. cout << '\n';
  21. for (int i : st){
  22. cout << i << ' ';
  23. }
  24. //system("pause");
  25. return 0;
  26. }

代码三

  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. int main(){
  4. int n;
  5. cin>>n;
  6. vector<int> a(n);
  7. for(int i = 0; i<n; i++) cin>>a[i];
  8. sort(a.begin(),a.end());
  9. for(int i = 0; i<n; i++) cout<<a[i]<<" ";
  10. cout<<endl;
  11. int res = a[0];
  12. cout<<res<<" ";
  13. for(int i = 1; i<n; i++){
  14. if(res != a[i]){
  15. res = a[i];
  16. cout<<res<<" ";
  17. }
  18. }
  19. cout<<endl;
  20. return 0;
  21. }
版权声明: 本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若内容造成侵权/违法违规/事实不符,请联系邮箱:809451989@qq.com进行投诉反馈,一经查实,立即删除!
网站建设 2026/5/12 0:09:32

百度网盘解析神器:5分钟学会高速下载技巧,轻松突破限制!

百度网盘解析神器&#xff1a;5分钟学会高速下载技巧&#xff0c;轻松突破限制&#xff01; 【免费下载链接】baidu-wangpan-parse 获取百度网盘分享文件的下载地址 项目地址: https://gitcode.com/gh_mirrors/ba/baidu-wangpan-parse 还在为百度网盘的下载速度而烦恼吗…

作者头像 李华
网站建设 2026/5/5 4:23:16

NVIDIA Profile Inspector:显卡性能终极调优神器深度解析

NVIDIA Profile Inspector&#xff1a;显卡性能终极调优神器深度解析 【免费下载链接】nvidiaProfileInspector 项目地址: https://gitcode.com/gh_mirrors/nv/nvidiaProfileInspector 还在为高价显卡无法发挥全部性能而烦恼吗&#xff1f;你的显卡可能正在"偷懒&…

作者头像 李华
网站建设 2026/4/28 17:31:04

百度网盘下载慢?3个实用技巧让你告别龟速下载

百度网盘下载慢&#xff1f;3个实用技巧让你告别龟速下载 【免费下载链接】baidu-wangpan-parse 获取百度网盘分享文件的下载地址 项目地址: https://gitcode.com/gh_mirrors/ba/baidu-wangpan-parse 还在为百度网盘那令人抓狂的下载速度而苦恼吗&#xff1f;当重要文件…

作者头像 李华
网站建设 2026/5/10 19:53:45

如何快速定制英雄联盟形象:终极身份伪装工具完整指南

如何快速定制英雄联盟形象&#xff1a;终极身份伪装工具完整指南 【免费下载链接】LeaguePrank 项目地址: https://gitcode.com/gh_mirrors/le/LeaguePrank 在英雄联盟的社交生态中&#xff0c;游戏形象往往决定了你的社交地位。面对段位焦虑和形象单一的困扰&#xff…

作者头像 李华
网站建设 2026/5/11 1:33:07

5个超实用技巧,让你的Windows右键菜单重获新生

5个超实用技巧&#xff0c;让你的Windows右键菜单重获新生 【免费下载链接】ContextMenuManager &#x1f5b1;️ 纯粹的Windows右键菜单管理程序 项目地址: https://gitcode.com/gh_mirrors/co/ContextMenuManager 你是否曾经对着拥挤不堪的右键菜单感到无奈&#xff1…

作者头像 李华
网站建设 2026/5/9 0:55:47

百度网盘直链解析终极教程:告别限速的简单方法

百度网盘直链解析终极教程&#xff1a;告别限速的简单方法 【免费下载链接】baidu-wangpan-parse 获取百度网盘分享文件的下载地址 项目地址: https://gitcode.com/gh_mirrors/ba/baidu-wangpan-parse 还在为百度网盘的龟速下载而烦恼吗&#xff1f;百度网盘直链解析工具…

作者头像 李华