c语言acm水题不会弄Descriptionfind the median of several integersInputThe first line of input is the number of test cases T(T

来源:学生作业帮助网 编辑:作业帮 时间:2024/05/09 19:22:22
c语言acm水题不会弄Descriptionfind the median of several integersInputThe first line of input is the number of test cases T(T

c语言acm水题不会弄Descriptionfind the median of several integersInputThe first line of input is the number of test cases T(T
c语言acm水题
不会弄
Description
find the median of several integers
Input
The first line of input is the number of test cases T(T

c语言acm水题不会弄Descriptionfind the median of several integersInputThe first line of input is the number of test cases T(T
#include <stdio.h>
void fun(double a[],int m){
    int i,j,temp;
    for(i=1;i<m;i++)
        for (j=0; j<m-i; j++) {
            if(a[j]>a[j+1]){
                temp   = a[j];
                a[j]   = a[j+1];
                a[j+1] = temp;
            }
        }
}//冒泡排序

int main(){
    int n,m,i;
    double a[111];
    double ave;
    while (~scanf("%d",&n)) {
        while (n--) {
            scanf("%d",&m);
            for(i=0;i<m;i++){
                scanf("%lf",&a[i]);
            }
            fun(a,m);
            if(m%2==1){
                ave=a[m/2];
            }//是奇数
            else{
                ave=(a[m/2]+a[m/2-1])/2;
            }//是偶数
            if(int(ave)*1.0==ave)
                printf("%d\n",(int)ave);//是整数
            else
                printf("%.1lf\n",ave);//是小数
               
        }
    }
}

c语言acm题 c语言acm水题不会弄Descriptionfind the median of several integersInputThe first line of input is the number of test cases T(T acm的一道c语言问题 水题啊!,但是不会做!ACm 北大ACM中第1001浮点数这题咋做啊?请高人用C语言帮我实现一下, 用C语言编写acm的题时,遇到整数很大,例如100,000,000,或者这个整数长度很长,例如1000,那该怎么定义我不怎么懂c语言,最好有实例,小弟在此万分感谢. 用c语言做acm题目有什么参考书推荐在poj做题,觉得自己对c语言了解不够,能推荐基本书吗,最好是电子书 我不会英语能学C语言 我不会英语能学C语言 我不会英语能学C语言 不会英语能学会C语言吗? C语言:ACM大数运算问题.--------------------------------------------------------------------------------Time limit:1000MS Memory limit:32768K Total Submit:204 Accepted:71 ------------------------------------------------------------------------- 我是用的是C语言,想在黑龙江省ACM大赛中拿三等奖,应该掌握那些算法…… 计算机上C语言 不会英语也能学吗计算机C语言 不会英语也能学吗 acm刷题是什么意思 ACM C语言 算法题现在给一个字典1,2,3,4,6,7,10,11,12,13,14,16,17……..47,60 即其中不包括5,8,9三个数,现任给一个字典中 要想做ACM的题,需要学什么知识我的学计算机的,但是一个初学者,看到有同学在做ACM的题,自己也想做,发现什么也不会,要想做这种题目应该学哪些知识?PS.我学了C,C++ 提供几道Dijkstra算法的ACM水题练习