#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. jq-css、class、属性操作

    <!DOCTYPE html><html lang="en"><head> <meta charset="UTF-8" ...

  2. HTML常用基础标签

    HTML常用基础标签 带有语义的标签 <em> </em> 强调 <strong> </strong> 比em强调级别高 <abbr> &l ...

  3. hdu5592 倒序求排列+权值线段树

    这种题为什么要用到主席树啊..8说了,直接上代码 /* 1-n的排列,给定所有前缀的逆序对数量,要求恢复排列 首先能确定最后一个数是什么,然后倒序确定即可 开线段树找空位:如果Ai-Ai-1=k,说明 ...

  4. git官网和安装使用教程链接

    git官网 https://git-scm.com/download/win git安装教程 https://www.cnblogs.com/wj-1314/p/7993819.html

  5. Three teachers who make differences in my life

    人生路漫漫,从小到大,经历过九年义务教育的我们也受到过很多老师的熏陶,而已经进入大学的我也会回想起那些给我带来别样意义的老师们. 亲爱的老李-老李是我初中的班主任,也是我的历史老师.依稀记得上他的课会 ...

  6. android setCompoundDrawables和setCompoundDrawablesWithIntrinsicBounds区别

    手工设置文本与图片相对位置时,常用到如下方法: setCompoundDrawables(left, top, right, bottom) setCompoundDrawablesWithIntri ...

  7. 蓝桥杯 购物单(使用word协助)

    标题: 购物单 小明刚刚找到工作,老板人很好,只是老板夫人很爱购物.老板忙的时候经常让小明帮忙到商场代为购物.小明很厌烦,但又不好推辞. 这不,XX大促销又来了!老板夫人开出了长长的购物单,都是有打折 ...

  8. Servlet(五):请求转发和重定向

    请求转发: 问题: 服务器在接收到浏览器的请求后,仅仅使用一个 Servlet进行请求处理,会造成不同的Servlet逻辑代码 冗余,Servlet的职责不明确. 解决: 使用请求转发. 特点: 一次 ...

  9. C++ log4cplus 类库的封装

    对 log4cplus 库的封装,修改自网路 LogUtils.h /* * LogUtils.h * * Created on: 2018年8月9日 * Author: oftenlin */ #i ...

  10. python is, ==区别

    “is” is the identity comparison. #比较引用是否相同 “==” is the equality comparison. #比较内容是否相同 >>> [ ...