求第N数大问题
问题:
Input
The first line of input contains a single integer P, (1 ≤ P ≤ 1000), which is the number of data sets that follow. Each data set consists of a single line containing the data set number, followed by a space, followed by 10 space separated decimal integers whose values are between 1 and 1000 inclusive.
Output
For each data set, generate one line of output with the following values: The data set number as a decimal integer, a space, and the 3rd largest value of the corresponding 10 integers.
Sample Input
4
1 1 2 3 4 5 6 7 8 9 1000
2 338 304 619 95 343 496 489 116 98 127
3 931 240 986 894 826 640 965 833 136 138
4 940 955 364 188 133 254 501 122 768 408
Sample Output
1 8
2 489
3 931
4 768
回答:题意输出10个数,求里面第3大数问题。如"1 2 3 4 5 6 7 8 9 1000"里面数值排第三是8。
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int main()
{
int T;
for(scanf("%d",&T);T;T--)
{
int ca,a[12];
scanf("%d",&ca);
for(int i=0;i<10;i++)
scanf("%d",a+i);
sort(a,a+10);
printf("%d %d\n",ca,a[7]);
}
return 0;
}
求第N数大问题的更多相关文章
- 评playerc网友的"求比指定数大且最小的“不重复数”问题"
问题见:对Alexia(minmin)网友代码的评论及对“求比指定数大且最小的‘不重复数’问题”代码的改进 .算法:求比指定数大且最小的“不重复数”问题的高效实现 . playerc网友的代码如下(求 ...
- 对Alexia(minmin)网友代码的评论及对“求比指定数大且最小的‘不重复数’问题”代码的改进
应Alexia(minmin)网友之邀,到她的博客上看了一下她的关于“求比指定数大且最小的‘不重复数’问题”的代码(百度2014研发类校园招聘笔试题解答),并在评论中粗略地发表了点意见. 由于感觉有些 ...
- sum_series() 求一列数的指定个数的数和(5个数字的和)
#include <stdio.h> #include <stdarg.h> /*用sum_series() 求一列数的指定个数的数和(5个数字的和)*/ double sum ...
- 分页过滤SQL求总条数SQL正则
public static void main(String[] args) throws Exception { String queryForScanUsers_SQL = "selec ...
- H面试程序(29):求最大递增数
要求:求最大递增数 如:1231123451 输出12345 #include<stdio.h> #include<assert.h> void find(char *s) { ...
- codeforces 429 On the Bench dp+排列组合 限制相邻元素,求合法序列数。
限制相邻元素,求合法序列数. /** 题目:On the Bench 链接:http://codeforces.com/problemset/problem/840/C 题意:求相邻的元素相乘不为平方 ...
- P1474 货币系统 Money Systems(完全背包求填充方案数)
题目链接:https://www.luogu.org/problemnew/show/1474 题目大意:有V种货币,求用V种货币凑出面值N有多少种方案. 解题思路:就是完全背包问题,只是将求最大价值 ...
- HDU 1171 Big Event in HDU【01背包/求两堆数分别求和以后的差最小】
Big Event in HDU Time Limit: 10000/5000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) T ...
- 【C语言】不使用大小于号,求出两数最大值
//不使用大小于号,求出两数最大值 #include <stdio.h> #include <math.h> double Max(double a, double b) { ...
随机推荐
- n个整数中,找出尽可能多的数使他们组成一个等差数列,求最长等差数列的长度
例子: 3,8,4,5,6,2 返回值应该为 :5 这是昨天做的一道优酷土豆的编程题,和leetcode中的128/ Longest Consecutive Sequence 有点 ...
- np问题
NP(np) Time Limit:1000ms Memory Limit:64MB 题目描述 LYK 喜欢研究一些比较困难的问题,比如 np 问题.这次它又遇到一个棘手的 np 问题.问题是这个样子 ...
- SqlMapConfig.xml中的setting属性设置
<settings cacheModelsEnabled="true" lazyLoadingEnabled="false" en ...
- 转: 最值得阅读学习的 10 个 C 语言开源项目代码
from: http://www.iteye.com/news/29665 1. Webbench Webbench是一个在linux下使用的非常简单的网站压测工具.它使用fork()模拟多个客户端同 ...
- React Native iOS环境搭建
前段时间React Native for Android发布,感觉React Native会越来越多的公司开始研究.使用.所以周六也抽空搭建了iOS的开发环境,以便以后利用空闲的时间能够学习一下. 废 ...
- window.lacation.replace
<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8&quo ...
- PHP 运行方式(PHP SAPI介绍)
SAPI:Server Application Programming Interface 服务器端应用编程端口.它就是PHP与其它应用交互的接口,PHP脚本要执行有很多种方式,通过Web服务器,或者 ...
- 006医疗项目-模块一:用户的查找:2.用户表查询的mapper映射的文件
前一篇文章已经把sql语句写好了并且在PL/SQL上调试过了,是可以的.这篇文章是写对应的mapper.xml, 第一步我们先通过逆向工程去构建每个表的mapper.xml文件和pojo类.这个我们在 ...
- anroid studio 找不到符号 位置: 类 drawable
一般是把图片加到mipmap之后写成R.drawable.xxx引起的
- 【转】【SEE】基于SSE指令集的程序设计简介
SSE技术简介 Intel公司的单指令多数据流式扩展(SSE,Streaming SIMD Extensions)技术能够有效增强CPU浮点运算的能力.Visual Studio .NET 2003提 ...