摘要: 1:给定三个整数a,b,c实现函数int median(int a,int b,int c),返回三个数的中位数,不可以使用sort,要求整数操作(比较,位运行,加减乘除)次数尽量少,并分析说明程序最坏和平均情况下使用的操作次数#include <stdio.h> #include <iostream>using namespace std;int median(int a,int b,int c){ int abMax = (a+b + abs(a-b))/2; int acMax = ((a+c) + abs(a-c))/2; if(abMax != acMax) 阅读全文
posted @ 2012-11-07 16:44 byfei 阅读(200) 评论(0) 推荐(0)