九度OJ题目1041:Simple Sorting解题报告

【gcc】跨版本兼容实战:高版本编译程序在低版本glibc环境下的部署方案 本文针对高版本gcc编译的程序在低版本glibc环境下部署的兼容性问题,提供了四种实战解决方案:静态编译的局限性、容器化部署的优雅方案、使用Devtoolset工具链的官方支持,以及最通用灵活的打包依赖SO发布方案。重点剖析了通过设置RPATH和Interpreter或使用patchelf工具,实现程序与自带库的独立部署,有效解决glibc版本鸿沟。 阅读详情
题目1041:Simple Sorting

时间限制:1 秒

内存限制:32 兆

特殊判题:否

提交:5352

解决:2047

题目描述:

You are given an unsorted array of integer numbers. Your task is to sort this array and kill possible duplicated elements occurring in it.

输入:

For each case, the first line of the input contains an integer number N representing the quantity of numbers in this array(1≤N≤1000). Next N lines contain N integer numbers(one number per each line) of the original array.

输出:

For each case ,outtput file should contain at most N numbers sorted in ascending order. Every number in the output file should occur only once.

样例输入:
6
8 8 7 3 7 7
样例输出:
3 7 8
解题分析:在做该题的时候,由于排序函数的问题,一直Wrong Answer,看了别人的排序函数之后,才做正确;输出格式也需要注意。思路是每次输入一个数的时候,判断该数是否已经出现过,若没有,则保存到一个新数组中,若已经出现过,则忽略,继续判断下一个输入数值。
       
for (i=0;i<n;i++){
         flag=1;
         scanf ( "%d" ,&num[i]);
         temp=num[i];
   for (j=0;j<count;j++){
     if (b[j]==temp){
         flag=0; break ;
     }
   }
   if (flag==1) b[count++]=temp;
      }
      
注意:
排序函数:
[cpp]  view plain  copy
  1. int cmp(const void *a, const void *b){  
  2.     return *(int *)a - *(int *)b;  
  3. }  
提交会Wrong 网友解释 :
如果a=2147483647,b=-2;就会出现a-b>0,结果溢出了。所以使用return *(int *)a>*(int *)b?1:-1;就对了
测试数据:
2
2147483647 -2
源代码:
      
#include <stdio.h>
#include <math.h>
#define MAXNUM 10000
int cmp ( const void *a , const void *b){
 
         return *( int *)a >*( int *)b?1:-1;
}
 
int main(){
int n,num[1005],b[1005],flag;
int i,count,j,temp;
while ( scanf ( "%d" ,&n)!=EOF){
 
     j=0,  count=0;flag=1;
      for (i=0;i<1005;i++)
         b[i]=-1;
      for (i=0;i<n;i++){
         flag=1;
         scanf ( "%d" ,&num[i]);
         temp=num[i];
   for (j=0;j<count;j++){
     if (b[j]==temp){
         flag=0; break ;
     }
   }
   if (flag==1) b[count++]=temp;
      }
qsort (b,count, sizeof (b[0]),cmp);
for (i=0;i<count-1;i++)
     printf ( "%d " ,b[i]);
 
  printf ( "%d\n" ,b[count-1]);
}
 
return 0;
}
 
/**************************************************************
     Problem: 1041
     User: kaoyandaren123
     Language: C
     Result: Accepted
     Time:0 ms
     Memory:912 kb
****************************************************************/
【AUTOSAR-COM】-5.2-“Deadline Monitoring超时监控”-2-基于IPdu实现 目录 1 在CFG中配置Deadline Monitoring超时监控 1.1 参数说明 1.2 生成代码差异 2 通过一段测试代码看Deadline Monitoring超时监控 3 使用CAN盒观察Deadline Monitoring实际测试效果 3.1 Case 1:ECU开始工作时,没有收到Frame 3.2 Case 2:ECU工作中,接收的Frame丢失、 4 小结 5 结尾 关键字: DM=Deadline Monitoring超时监控 ComFirstTime... 阅读详情

相关推荐

UDS诊断ISO14229新手入门篇

这个命令的格式稍微复杂一点。sub-function = 0x06 用于读取某个 DTC 及其相关的环境数据,此时 parameter 为 4 个 byte,前三个 byte 用于标识我们要读取的 DTC,第四个 byte 用于标识要读取的环境数据的范围,UDS 规定使用 FF 来表示读取所有的环境数据,各厂家可以要根据自己的需求定义其他的值来代表要读取的环境数据的范围。环境数据包括 DTC 状态,优先级,发生次数,老化计数器,时间戳,里程等,厂家还可以根据自己的需求定义一些此 DTC 产生时的测量数据。

weixin_45387165的博客 1974

【c/c++】Simple Sorting

题目链接 题目描述 You are given an unsorted array of integer numbers. Your task is to sort this array and kill possible duplicated elements occurring in it. 给你一个未排序的整数数组。您的任务是对该数组进行排序,并消除其中可能出现的重复元素。 输入描述 For each case, the first line of the input contains an inte

叶柖的博客 198

Delphi开发者必备:CEF4Delphi跨平台浏览器嵌入实战指南(含Lazarus适配)

本文详细介绍了Delphi开发者如何利用CEF4Delphi实现跨平台浏览器嵌入,包括环境配置、Lazarus适配、ARM架构优化及Firemonkey集成等实战技巧。通过Chromium引擎的强大功能,开发者可以轻松为传统桌面应用添加现代浏览器特性,提升多平台开发效率。

weixin_29233333的博客 229

上海交通大学 Simple Sorting(java)

题目描述 You are given an unsorted array of integer numbers. Your task is to sort this array and kill possible duplicated elements occurring in it. 输入描述: For each case, the first line of the input contain...

weixin_43306331的博客 479

别再调PID了!用MATLAB/Simulink给四旋翼无人机搭个ADRC控制器(附完整仿真模型)

本文详细介绍了在MATLAB/Simulink环境中为四旋翼无人机搭建ADRC控制器的完整流程,包括核心原理、Simulink建模、参数调试技巧及与PID控制的性能对比。ADRC通过扩张状态观测器(ESO)有效提升无人机在复杂扰动下的控制性能,特别适合四旋翼无人机这类强耦合系统。文章还提供了完整的仿真模型和工程实践问题解决方案。

weixin_26808439的博客 382

【麒麟桌面系统】企业微信提示当前副设备的企业微信版本较低

银河麒麟系统中登录企业微信时出现"副设备版本较低"的报错,可通过两种方案解决:1)更新最新版企业微信,需替换软件源并刷新软件商店安装8.0-50-4.1.26.6019kylin5版本;2)安装内测5.0版本企业微信,需下载deb包后使用sudo dpkg命令安装。文章还提供了常见问题解决表和长期维护建议,包括系统更新检查、软件源验证等维护项目及具体操作指南。

信创运维工程师 · 银河麒麟 & 容器实战 | 金融生产环境迁移·等保加固 | 142篇原创·17万+阅读 2276

九度oj1041

题目1041:Simple Sorting 时间限制: 1 秒 内存限制: 32 兆 特殊判题: 否 提交: 2365 解决: 923 题目描述: You are given an unsorted array of integer numbers. Your task is to sort this array and kill possible duplicated

博客园的粉丝 680

模型预测控制(MPC)解析(三):多输入多输出系统

本文为阅读笔记,仅供学习交流使用!!! 在之前的文章中,为了简单起见,以单输入单输出系统为例介绍了MPC控制的实现方法。因为使用的是状态空间方程作为系统模型,这种方法可以轻松的扩展到多输入多输出系统中。 ...

行者无疆的博客 1万+

题目1041:Simple Sorting-------注意最后一个数字的处理

#include<stdio.h> #include<algorithm> using namespace std; int a[1001]; int main() { int N; while(scanf("%d",&N)!=EOF) { int i; for(i=0;i<N;i...

weixin_30660027的博客 146

MC_SetOverride指令详细应用介绍(基恩士PLC)

基恩士KV系列PLC和松下总线绝对值伺服运动控制(详细配置+轴控完整ST源代码)

RXXW_Dor的博客 336

YOLOv11 改进 - 主干网络| 清华大学CloFormer AttnConv :利用共享权重和上下文感知权重增强局部感知,注意力机制与卷积的完美融合

本文介绍了轻量级视觉变换器CloFormer及其核心模块AttnConv在YOLOv11中的结合应用。为解决视觉变换器缩小到移动设备友好尺寸时性能下降的问题,提出CloFormer,其引入AttnConv操作符。AttnConv融合共享权重和上下文感知权重,先通过深度卷积提取局部表示,再用上下文感知权重增强特征,还结合传统注意力减少FLOPs,使模型感知高频和低频信息。我们将AttnConv集成进YOLOv11,实验表明,CloFormer在多个视觉任务中表现优越,改进后的YOLOv11也取得了良好实验结果

魔改工程师的博客 989

九度OJ 题目1041:Simple Sorting

题目1041:Simple Sorting 时间限制:1 秒 内存限制:32 兆 特殊判题:否 提交:1654 解决:630 题目描述: You are given an unsorted array of integer numbers. Your task is to sort this array and kill possible

落日小屋 1303

YOLOv8【第一章:基础入门篇·第2节】一文搞定,数据集制作与标注完全指南!

🏆 本文收录于 《YOLOv8实战:从入门到深度优化》 专栏,该专栏专注于分享我在YOLOv8目标检测模型中的实战经验,涵盖从入门基础到深度优化的全方位解决方案。无论你是计算机视觉的新手,还是具有多年深度学习经验的专家,本专栏都将为你提供高效、可复现的技术方案,助你掌握YOLOv8的核心技术,提升目标检测性能,突破瓶颈,优化模型,并加速项目开发🚀!

**My Coding Family** 1509

九度OJ题目1041:Simple Sorting

题目1041:Simple Sorting 时间限制:1 秒 内存限制:32 兆 特殊判题:否 提交:4072 解决:1520 题目描述: You are given an unsorted array of integer numbers. Your task is to sort this array and kill possible

AdamChinaren的专栏 585

Statistics and Machine Learning Toolbox

Statistics and Machine Learning Toolbox(带书签),MATLAB统计学习工具

NTscan扫描工具

ntscan是一个扫描器,可以扫描没有密码和弱密码的共享,先到配置文件中填写猜测的用户名和密码,扫描过程中右侧出现的是扫描日志。

九度oj 题目1041:Simple Sorting

题目描述: You are given an unsorted array of integer numbers. Your task is to sort this array and kill possible duplicated elements occurring in it. 输入: For each case, the first line of the input ...

aling1199的博客 119

复分析 阿尔福斯(Ahlfors) 第三版答案 英文

答案分为十章,有部分习题没有答案,全英文复分析阿尔福斯(Ahlfors) 第三版答案

九度OJ 1041 Simple Sorting (排序,STL)

题目1041:Simple Sorting 时间限制:1 秒 内存限制:32 兆 特殊判题:否 提交:3971 解决:1483 题目描述: You are given an unsorted array of integer numbers. Your task is to sort this array and kill possible

芝兰生于深谷,不以无人而不芳 1979

九度OJ1041-Simple Sorting【快排】

题目1041:Simple Sorting 时间限制:1 秒 内存限制:32 兆 特殊判题:否 提交:4521 解决:1691 题目描述: You are given an unsorted array of integer numbers. Your task is to sort this array and kill possible duplicated elements o...

小I的博客 574

九度oj-1041-Simple Sorting

时间限制:1 秒 内存限制:32 兆 特殊判题:否 提交:4515 解决:1688 题目描述: You are given an unsorted array of integer numbers. Your task is to sort this array and kill possible duplicated elements occurrin

u011514451的专栏 393

九度OJ 1041:Simple Sorting(简单排序) (排序)

时间限制:1 秒 内存限制:32 兆 特殊判题:否 提交:4502 解决:1680 题目描述: You are given an unsorted array of integer numbers. Your task is to sort this array and kill possible duplicated elements occurrin

梁山伯的专栏 593

九度OJ---1041

http://ac.jobdu.com/problem.php?pid=1041 import java.util.Iterator; import java.util.Scanner; import java.util.TreeSet;   public class Main {       public s

垂钓者--临溪 825

<C/C++基础>九度OJ题目1000--1049解题练习(二)

题目1000:计算a+b 题目描述: 求整数a,b的和。 输入:

EbowTang的练习场 4258

题目1041:Simple Sorting

http://ac.jobdu.com/problem.php?pid=1041 // 坑爹的一道题,不能用qsort( )或sort( )排序函数,必须自己写一个排序。。。  #include int main() {     int i,j,t,n,a[1005];     while(scanf("%d",&n)!=EOF){         for(i=0;i

恋&空的专栏 664

九度OJ 1041 简单排序

题目描述: You are given an unsorted array of integer numbers. Your task is to sort this array and kill possible duplicated elements occurring in it. 输入: For each case, the first line of the inp

Jaster_wisdom的专栏 902

九度OJ题目1193:矩阵转置解题报告

题目1193:矩阵转置 时间限制:1 秒 内存限制:32 兆 特殊判题:否 提交:2263 解决:1501 题目描述: 输入一个N*N的矩阵,将其转置后输出。要求:不得使用任何数组(就地逆置)。 输入: 输入的第一行包括一个整数N,(1 接下来的N行每行有N个整数,分别代表矩阵的元素。 输出: 可能有多组测

It_BeeCoder的博客 991

九度oj题目1088:剩下的树解题报告

题目1088:剩下的树 时间限制:1 秒 内存限制:32 兆 特殊判题:否 提交:9038 解决:4165 题目描述:     有一个长度为整数L(1     现在要移走一些树,移走的树的区间用一对数字表示,如 100 200表示移走从100到200之间(包括端点)所有的树。     可能有M(1 输入:     两个整

It_BeeCoder的博客 910

九度OJ题目1081:递推数列解题报告

题目1081:递推数列 时间限制:1 秒 内存限制:32 兆 特殊判题:否 提交:7791 解决:1088 题目描述: 给定a0,a1,以及an=p*a(n-1) + q*a(n-2)中的p,q。这里n >= 2。 求第k个数对10000的模。 输入: 输入包括5个整数:a0、a1、p、q、k。 输出:

It_BeeCoder的博客 817

九度OJ1099:后缀子串排序解题报告

题目1099:后缀子串排序 时间限制:1 秒 内存限制:32 兆 特殊判题:否 提交:4500 解决:2007 题目描述: 对于一个字符串,将其后缀子串进行排序,例如grain 其子串有: grain  rain  ain  in  n 然后对各子串按字典顺序排序,即:  ain,grain,in,n,rain

It_BeeCoder的博客 809
上一篇: 编程有用博客地址
下一篇: 九度OJ题目1013:开门人和关门人解题报告
It_BeeCoder
博客等级 码龄10年 967粉丝 238原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值