#include <stdio.h>
#include <stdlib.h>
#include <math.h> #define MAXSIZE 1000 int comp_inc(const void *first, const void *second); int main()
{
int Median_ind_1;
int Median_ind_2;
int n;
scanf("%d", &n);
int i;
int seq[MAXSIZE];
for(i=0; i<n; ++i)
scanf("%d", &seq[i]);
qsort(seq, n, sizeof(seq[0]), comp_inc);
for(i=0; i<n; ++i)
{
if(i!=0)
printf(" ");
printf("%d", seq[i]);
}
printf("\n");
Median_ind_1=ceil(n/2);
int temp=n-1;
Median_ind_2=((temp-1)/2)+1;
printf("Median_ind_1=%d; Median=%d\n", Median_ind_1, seq[Median_ind_1]);
printf("Median_ind_2=%d; Median=%d\n", Median_ind_2, seq[Median_ind_2]);
return 0;
} int comp_inc(const void *first, const void *second)
{ return *(int *)first-*(int *)second;
}

  

Median的更多相关文章

  1. No.004:Median of Two Sorted Arrays

    问题: There are two sorted arrays nums1 and nums2 of size m and n respectively.Find the median of the ...

  2. [LeetCode] Find Median from Data Stream 找出数据流的中位数

    Median is the middle value in an ordered integer list. If the size of the list is even, there is no ...

  3. [LeetCode] Median of Two Sorted Arrays 两个有序数组的中位数

    There are two sorted arrays nums1 and nums2 of size m and n respectively. Find the median of the two ...

  4. Applying vector median filter on RGB image based on matlab

    前言: 最近想看看矢量中值滤波(Vector median filter, VMF)在GRB图像上的滤波效果,意外的是找了一大圈却发现网上没有现成的code,所以通过matab亲自实现了一个,需要学习 ...

  5. 【leetcode】Median of Two Sorted Arrays

    题目简述: There are two sorted arrays A and B of size m and n respectively. Find the median of the two s ...

  6. Codeforces Round #327 (Div. 2) B. Rebranding C. Median Smoothing

    B. Rebranding The name of one small but proud corporation consists of n lowercase English letters. T ...

  7. 【leedcode】 Median of Two Sorted Arrays

    https://leetcode.com/problems/median-of-two-sorted-arrays/ There are two sorted arrays nums1 and num ...

  8. Find Median from Data Stream

    常规方法 超时 class MedianFinder { vector<int> coll; public: MedianFinder(){ } void heapfu(vector< ...

  9. 数据结构与算法(1)支线任务8——Find Median from Data Stream

    题目如下:(https://leetcode.com/problems/find-median-from-data-stream/) Median is the middle value in an ...

  10. leetcode-【hard】4. Median of Two Sorted Arrays

    题目 There are two sorted arrays nums1 and nums2 of size m and n respectively. Find the median of the ...

随机推荐

  1. Python内置函数之classmetho staticmethod

    当对类的静态属性进行修改时(不需要借助于对象就行类静态属性的修改) class Goods: discount = 0.5 def __init__(self,name,price): self.na ...

  2. JS语法转换-ES6转ES5

    1.使用Babel转码 全局安装 npm install -g babel-cli 布局安装 npm install -g babel-cli --save-dev Babel的配置文件是.babel ...

  3. Spring以及tomcat中的Listener

    tomcat容器的listener: ServletContextListener HttpSessionListener ServletRequestListener Spring的listener ...

  4. win10安装Oracle11g-出现INS-13001环境不满足最低要求问题

    今天安装Oracle11g,出现INS-13001环境不满足最低要求问题: 解决方法 在安装时点击setup.exe之后,出现了:[INS-13001]环境不满足最低要求 这时,打开你的解压后的dat ...

  5. teamviewer连接未就绪的解决(Manjaro Linux)

    放假回家,想设置一下teamviewer,结果一直报错"TeamViewer not ready. Please check your connection" 查了一通,发现这个方 ...

  6. 最简单的SQLserver,发布订阅教程,保证一次就成功

    最简单的SQLserver,发布订阅教程,保证一次就成功 发布订阅用来做数据库的读写分离,还是很好用的 当单台数据库的压力太大时,可以考虑这种方案,一主多从,主服务器的数据库只管写入,其他的数据库都是 ...

  7. Django表单字段汇总

    Field.clean(value)[source] 虽然表单字段的Field类主要使用在Form类中,但也可以直接实例化它们来使用,以便更好地了解它们是如何工作的.每个Field的实例都有一个cle ...

  8. Intellij IDEA导入eclipse项目配置jdk、tomcat到浏览器正常访问

    转发自:博客园---Lindp(大佬写的甚好) 以下是转发的正文 intellij idea中文资料网上比较少,对于eclipse的项目如何导入intellij idea也没有完整的说明,本人在这里整 ...

  9. Hibernate 双向一对多映射

    附代码: public class Order { private Integer id; private String OrderName; private Customer customer; p ...

  10. c#学习个人总结

    c#一门程序语言,我的专业课.有了一学期的接触对它的了解还只是皮毛,里面有许多的知识都有待了解学习和提高,熟练掌握程序的语法,能够熟练的调用,对于一些理论性的知识还需要今后更多的揣摩和研究,讲书本中的 ...