还是水题,简单的排序。大半夜的,没脑子想太复杂的代码了,就随手找了段以前写的插入排序将就着用了。

题目的意思就是取一个数列的中位数,很简单,排序后取a[n/2]即可。

代码如下:

 #ifndef _2388_H
#define _2388_H #include "stdio.h" #define ARRAY_LENGTH 10000 int array[ARRAY_LENGTH]; void insertSort(int array[ARRAY_LENGTH], int len) {
int i, j, key;
for (j = ; j < len; j++) {
i = j - ;
key = array[j];
while (i >= && array[i] > key) {
array[i + ] = array[i];
i--;
}
array[i + ] = key;
}
} void process(){
int n, i = ;
scanf_s("%d", &n);
for (; i < n; i++){
scanf_s("%d", &array[i]);
}
insertSort(array, n);
printf("%d\n", array[n / ]);
}
#endif

POJ 2388的更多相关文章

  1. poj 2388 insert sorting

    /** \brief poj 2388 insert sorting 2015 6 12 * * \param * \param * \return * */ #include <iostrea ...

  2. POJ 2388 Who's in the Middle(水~奇数个数排序求中位数)

    题目链接:http://poj.org/problem?id=2388 题目大意: 奇数个数排序求中位数 解题思路:看代码吧! AC Code: #include<stdio.h> #in ...

  3. POJ 2388(排序)

    http://poj.org/problem?id=2388 题意:就N个数的中位数. 思路:用快排就行了.但我没用快排,我自己写了一个堆来做这个题.主要还是因为堆不怎么会,这个拿来练练手. #inc ...

  4. POJ 2388&&2299

    排序(水题)专题,毕竟如果只排序不进行任何操作都是极其简单的. 事实上,排序算法十分常用,在各类高级的算法中往往扮演着一个辅助的部分. 它看上去很普通,但实际的作用却很大.许多算法在失去排序后将会无法 ...

  5. poj 2388 Who's in the Middle

    点击打开链接 Who's in the Middle Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 28324   Acce ...

  6. POJ 2388 Who's in the Middle (快速选择算法:O(N)求数列第K大)

    [题意]求数列中间项. ---这里可以扩展到数列第K项. 第一次做的时候直接排序水过了= =--这一次回头来学O(N)的快速选择算法. 快速选择算法基于快速排序的过程,每个阶段我们选择一个数为基准,并 ...

  7. poj 2388 Who&#39;s in the Middle

    Who's in the Middle Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 31149   Accepted: 1 ...

  8. Who's in the Middle - poj 2388 (快速排序寻找中位数)

    题意; 寻找中位数 利用快速排序来寻找中位数. #include <iostream> using namespace std; int N; ]; int Median(int left ...

  9. POJ 2388:Who&#39;s in the Middle

    Who's in the Middle Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 31015   Accepted: 1 ...

随机推荐

  1. office web apps 整合Java web项目

    之前两篇文章将服务器安装好了,项目主要的就是这么讲其整合到我们的项目中,网上大部分都是asp.net的,很少有介绍Java如何整合的,经过百度,终于将其整合到了我的项目中. 首先建个servlet拦截 ...

  2. poj3160强连通分量加dfs

    After retirement as contestant from WHU ACM Team, flymouse volunteered to do the odds and ends such ...

  3. PXC5.7集群部署

    PXC三节点安装: node1:10.157.26.132 node2:10.157.26.133 node3:10.157.26.134   配置服务器ssh登录无密码验证 ssh-keygen实现 ...

  4. ConcurrentSkipListMap深入分析

    1.前言 ConcurrentHashMap与ConcurrentSkipListMap性能测试 在4线程1.6万数据的条件下,ConcurrentHashMap 存取速度是ConcurrentSki ...

  5. PHP电商订单自动确认收货redis队列

    一.场景 之前做的电商平台,用户在收到货之后,大部分都不会主动的点击确认收货,导致给商家结款的时候,商家各种投诉,于是就根据需求,要做一个订单在发货之后的x天自动确认收货.所谓的订单自动确认收货,就是 ...

  6. MyBatis和Hibernate相比,优势在哪里?

    1.开发对比开发速度 hibernate的真正掌握要比Mybatis来得难些.Mybatis框架相对简单很容易上手,但也相对简陋些.个人觉得要用好Mybatis还是首先要先理解好Hibernate. ...

  7. MyBatis源码解读(3)——MapperMethod

    在前面两篇的MyBatis源码解读中,我们一路跟踪到了MapperProxy,知道了尽管是使用了动态代理技术使得我们能直接使用接口方法.为巩固加深动态代理,我们不妨再来回忆一遍何为动态代理. 我相信在 ...

  8. Unity之2D Sprite Outline外轮廓效果

    操作系统:Windows8.1 显卡:Nivida GTX965M 开发工具:Unity5.3.8f1 Unity提供了2D Object Sprite对象,但是没有提供外轮廓Outline效果的支持 ...

  9. struts2.5能不能再恶心点

    Caused by: java.lang.IllegalArgumentException: unknown reserved key '_typeConverter' at ognl.OgnlCon ...

  10. JDBC进阶

    PreparedStatement的使用: conn = DriverManager.getConnection("jdbc:mysql://localhost/mydata?" ...