Microsoft的考验――查找第二大的数
#include<stdio.h>
int main()
{
int n,m,t,max,max1;
scanf("%d",&n);
while(n--)
{
max=-;
max1=-;
scanf("%d",&m);
while(m--)
{
scanf("%d",&t);
if(t==max || t==max1) continue;
if(t>max)
{
max1=max;
max=t;
}
else
{
if(t>max1)
{
max1=t;
}
}
}
if(max1!=- && max!=max1)
printf("%d\n",max1);
else
printf("None\n");
}
}
Microsoft的考验――查找第二大的数的更多相关文章
- c# 各种排序算法+找第二大的数+句子单词反转
冒泡排序 // 冒泡排序 bubble sort public static int[] BubbleSort(int []array) { bool isContinue = true; ; i & ...
- 如何使用一次for循环得到数组中第二大的数和第三大的数
装载声明:http://blog.csdn.net/lxsmk9059/article/details/77920206?locationNum=1&fps=1 ,,,,,,,,}; ]; ] ...
- python找出数组中第二大的数
#!usr/bin/env python #encoding:utf-8 ''''' __Author__:沂水寒城 功能:找出数组中第2大的数字 ''' def find_Second_large_ ...
- sql求倒数第二大的数,效率不高,但写法新颖
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.T ...
- 找第二大的数SQL-Second Highest Salary
1: 找小于最大的最大的 select max(Salary) from Employee where Salary<(select MAX(Salary) from Employee); 2. ...
- POJ 2985 The k-th Largest Group(树状数组 并查集/查找第k大的数)
传送门 The k-th Largest Group Time Limit: 2000MS Memory Limit: 131072K Total Submissions: 8690 Acce ...
- 基于快速排序思想partition查找第K大的数或者第K小的数。
快速排序 下面是之前实现过的快速排序的代码. function quickSort(a,left,right){ if(left==right)return; let key=partition(a, ...
- 快速排序及查找第K个大的数。
本文提供了一种基于分治法思想的,查找第K个大的数,可以使得时间复杂地低于nlogn. 因为快排的平均时间复杂度为nlogn,但是快排是全部序列的排序, 本文查找第k大的数,则不必对整个序列进行排序.请 ...
- HDU2512 一卡通大冒险 —— 第二类斯特林数
题目链接:https://vjudge.net/problem/HDU-2512 一卡通大冒险 Time Limit: 2000/1000 MS (Java/Others) Memory Lim ...
随机推荐
- Python 02 编写代码
原文:https://www.cnblogs.com/jimmy-share/p/9784219.html 方式: 交互式编程:打开python.exe文件后,直接输入代码即可.文件的位置(我本地): ...
- Awesome Go精选的Go框架,库和软件的精选清单.A curated list of awesome Go frameworks, libraries and software
Awesome Go financial support to Awesome Go A curated list of awesome Go frameworks, libraries a ...
- Redis代码示例
RedisTemplate 如果想要在java中使用Redis相关的数据结构,要先注入RedisTemplate. @Autowired private RedisTemplate<K,V> ...
- CTF PHP反序列化
目录 php反序列化 一.序列化 二.魔术方法 1.构造函数和析构函数 2.__sleep()和__wakeup() 3.__toString() 4.__set(), __get(), __isse ...
- 设置应用程序的样式并对其进行部署——《Python编程从入门到实践》
我们将使用应用程序django-bootstrap3为Web应用程序设计样式.我们将把项目"学习笔记"部署到Heroku,这个网站能让我们们将项目推送到其服务器,让任何有网络连接的 ...
- Nginx简单配置几个基于端口的虚拟主机
nginx.conf中,一个server段对应一个虚拟主机,如果要增加多个虚拟主机,增加多个server段即可. server { listen ; access_log logs/.log; loc ...
- 不使用BASE64Encoder、BASE64Decoder
BASE64Encoder/BASE64Decoder类在sun.misc包下,是sun公司的内部方法,后期有删除的潜在可能,建议使用apache commons.codec下的Base64替代. m ...
- 关于将汉语拼音字母“ü”改成“v”的设想和建议
http://bbs.tianya.cn/post-free-1667253-1.shtml?_t=t -- 徐州工业职业技术学院 孙生强 <汉语拼音方案>为中国人的语言文字学习带来极大方 ...
- 根据 sitemap 的规则[0],当前页面 [pages/index/index] 将被索引
sitemap 的索引提示是默认开启的,如需要关闭 sitemap 的索引提示,可在小程序项目配置文件 project.config.json 的 setting 中配置字段 checkSiteMap ...
- 123456123456#1#---###3%%%----com.zzj.SuperPuperID668---前拼show后广--嘻哈水管工-111111
com.zzj.SuperPuperID668---前拼show后广--嘻哈水管工-1111111111111