news 2026/6/15 12:50:33

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/6/14 1:27:14

百度网盘直链解析终极教程:3步解锁全速下载体验

还在为百度网盘的下载限速而烦恼吗&#xff1f;每次看到几十KB的龟速下载&#xff0c;是不是感觉时间都被浪费在了等待上&#xff1f;这款百度网盘直链解析工具正是你需要的解决方案&#xff0c;它能帮你提取真实下载链接&#xff0c;让下载速度实现质的飞跃&#xff01; 【免费…

作者头像 李华
网站建设 2026/6/14 23:03:49

百度网盘下载助手:优化下载体验,提升下载效率

还在为百度网盘的下载速度而烦恼吗&#xff1f;每次看到只有几KB/s的缓慢下载&#xff0c;是不是感觉时间都被白白浪费掉了&#xff1f;别担心&#xff0c;今天要介绍的这款百度网盘解析工具&#xff0c;正是专为解决这一痛点而生&#xff0c;让你轻松获取分享文件的真实下载地…

作者头像 李华
网站建设 2026/6/15 13:24:35

Unity游戏翻译终极解决方案:XUnity.AutoTranslator完全配置手册

Unity游戏翻译终极解决方案&#xff1a;XUnity.AutoTranslator完全配置手册 【免费下载链接】XUnity.AutoTranslator 项目地址: https://gitcode.com/gh_mirrors/xu/XUnity.AutoTranslator 还在为Unity游戏中的外文文本困扰吗&#xff1f;想要一键实现游戏本地化却不知…

作者头像 李华
网站建设 2026/6/14 22:54:19

Windows右键菜单深度优化:ContextMenuManager实战应用手册

Windows右键菜单深度优化&#xff1a;ContextMenuManager实战应用手册 【免费下载链接】ContextMenuManager &#x1f5b1;️ 纯粹的Windows右键菜单管理程序 项目地址: https://gitcode.com/gh_mirrors/co/ContextMenuManager 你是否曾为Windows右键菜单的臃肿不堪而烦…

作者头像 李华
网站建设 2026/6/14 21:39:56

NVIDIA Profile Inspector终极指南:5大核心功能深度解析与实战配置

NVIDIA Profile Inspector终极指南&#xff1a;5大核心功能深度解析与实战配置 【免费下载链接】nvidiaProfileInspector 项目地址: https://gitcode.com/gh_mirrors/nv/nvidiaProfileInspector 还在为游戏画面撕裂、帧率不稳而烦恼&#xff1f;NVIDIA Profile Inspect…

作者头像 李华
网站建设 2026/6/15 12:27:24

Unity游戏翻译终极指南:一键突破语言障碍的完整方案

Unity游戏翻译终极指南&#xff1a;一键突破语言障碍的完整方案 【免费下载链接】XUnity.AutoTranslator 项目地址: https://gitcode.com/gh_mirrors/xu/XUnity.AutoTranslator 还在为心爱的Unity游戏没有中文版而苦恼吗&#xff1f;&#x1f3ae; 面对满屏的外文界面和…

作者头像 李华