原题:OpenJudge - 19:Duplicate Number

翻译:

描述:给定一个N个数的序列,求一个在序列中的至少出现2次的数A;

输入:第一行:一个不大于1000的正整数N ;

第二行:N个正整数(< = 1000000);

输出:一个整数A。

代码:

#include<iostream>
#include<algorithm>
using namespace std;
int a[1010];
int main()
{int n,i;cin>>n;for(i=0;i<n;i++) scanf("%d",&a[i]);sort(a,a+n);for(i=1;i<n;i++)if(a[i]==a[i-1]){cout<<a[i];break;}return 0;
}

D19:Duplicate Number(重复数字,翻译+题解)相关推荐

  1. 中英翻译《The number thirteen数字13》

    The number thirteen 数字13 一.Pre-reading activity 阅前思考 1.Do you have a lucky number? If so, what is it ...

  2. 287. **Find the Duplicate Number

    287. **Find the Duplicate Number https://leetcode.com/problems/find-the-duplicate-number/description ...

  3. LeetCode 287. Find the Duplicate Number (时间复杂度O(n)) + 链表判断环

    LeetCode 287. Find the Duplicate Number 暴力解法 时间 O(nlog(n)),空间O(n),按题目中Note"只用O(1)的空间",照理是过 ...

  4. python3 数组重复数字,[python3] 3_01 数组中重复的数字

    题目如下 题目.png 思路1 将输入数组排序,从头到尾扫描排序后的数组. 代码如下 # 03_01_FindDuplication.py class Solution(object): def du ...

  5. 有重复数字的组合问题_带数字重复的组合和问题

    有重复数字的组合问题 Description: 描述: This is a standard interview problem to make some combination of the num ...

  6. linux找出重复数字,C语言笔试经典-查找多位数重复数字以及次数

    从键盘输入一个多位的整数 用程序判断 这个数里面有没有 重复的数字  有重复的数字就打印  哪个数字重复了  重复了几次 例如:输入:1122431 打印结果: 1重复 出现3次 2重复 出现2次, ...

  7. LeetCode 287. Find the Duplicate Number

    题目: Given an array nums containing n + 1 integers where each integer is between 1 and n (inclusive), ...

  8. LeetCode.287 Find the Duplicate Number

    题目: Given an array nums containing n + 1 integers where each integer is between 1 and n (inclusive), ...

  9. LintCode Find the Duplicate Number

    Given an array nums containing n + 1 integers where each integer is between 1 and n (inclusive), pro ...

最新文章

  1. 教你如何以对象的方式思考
  2. php滑动换视频,php工具类之【视频变换类】
  3. 中山大学2016年硕士研究生入学考试复试基本分数线
  4. Activity-数据状态的保存
  5. 一步一步使用标c编写跨平台图像处理库_让一个图像变成反向图像
  6. 使用EasyUI加载树形菜单
  7. 网关 架构演进及实践
  8. IDEA必备的10款插件
  9. windows扫雷的模拟实现(C语言)
  10. python循环中释放内存的方法_我怎样才能在Python中明确释放内存?
  11. java有除数为零_java语言中除数为零问题
  12. 2021年南京天印中学高考成绩查询,2021年南京重点高中名单及排名,南京高中高考成绩排名榜...
  13. 【计算机网络】三传输层--可靠传输原理rdt、GBN、SR
  14. 我读猫扑的《大王直言拷问网络写手良心》
  15. Windows Snapshot Grabber 2020中文版
  16. arcgis怎么压缩tif文件_怎么把图片文件大小压缩到25k到40k还比较清晰
  17. 【STM32+cubemx】0020 HAL库开发:以太网ENC28J60芯片和TCP、UDP简单应用
  18. 什么是索引?为什么需要索引?索引的优劣势?
  19. 一篇文章带你认识 Java 异常以及如何处理异常
  20. Java-pdf无限压缩方案-优化内存问题

热门文章

  1. 所谓的内存释放工具——原理
  2. Activiti6--入门学习--结束事件
  3. 蓝牙最新版本6.0_连续看影视最新版本下载2021-连续看影视无广告不升级版v1.6.0 安卓版...
  4. 学会了30个安慰自己和别人的技巧,你会更快乐
  5. python - windows 之 win32api资料教程与函数大全
  6. Windows 找不到文件 “gpedit.msc” ?解决方法:
  7. 【C语言跬步积累】——分支和循环总汇
  8. DRA821 环境搭建
  9. AddressSanitizer使用介绍
  10. 【Python】链家网二手房购房决策树