GfMath
来源:互联网 发布:linux如何卸载mysql 编辑:程序博客网 时间:2024/06/01 16:39
GfMath.h
#ifndef __GFMATH_H__#define __GFMATH_H__u32 wordAbs(u32,u32);int intAbs(int, int);int byteAbs(int , int);int sameSign(int a,int b,int c);int getMid(int a,int b,int c);int inRange(int a,int b,int c);int getNext(int now,int pre);#endif
GfMath.c
#include "All_includes.h"u32 wordAbs(u32 a, u32 b){ if(a > b) return (a - b); else return (b - a);}int intAbs(int a, int b){ if(a > b) return (int)(a - b); else return (int)(b - a);}int byteAbs(int a, int b){ if(a > b) return (int)(a - b); else return (int)(b - a);}int sameSign(int a,int b,int c){ if ( a==200 || b==200 || c==200 ) return 0; if ( byteAbs(a,b)>5 || byteAbs(b,c)>5 || byteAbs(a,c)>5 ) return 0; if ( a<=b && b<=c || a>=b && b>=c ) return 1; return 0;}int getMid(int a,int b,int c){ if(a > b){a ^= b ^= a ^= b} if(b > c){b ^= c ^= b ^= c} if(a > b){a ^= b ^= a ^= b} return b;}int inRange(int pre,int now,int next){ if (now == pre && pre == 0) { //允许跳一半 if (next < 80) return 1; else return 0; } if (now == pre && pre == 160) { if (next > 80) return 1; else return 0; } if (pre > now) { if (next <= now) { if (MAX((now << 1) - pre - 5, 0) <= next) return 1; } else { if (pre - now + next - now < 5) return 1; } } else { if (next >= now){ if (next <= MIN((now << 1) - pre + 5, 160)) return 1; } else { if (now - pre + now - next < 5) return 1; } } return 0;}int getNext(int now,int pre){ int next; if ( now > pre ) { next = MIN((int)((now << 1) - pre), 160); } else if ((now << 1) > pre) { next = (now << 1) - pre; } else next = 0; return next;}
- GfMath
- 三、lucene3.5的分词语法[停用词扩展、同义词搜索等]
- Install Nginx and PHP on OS X Mountain Lion (10.8)
- hibernate一、二级缓存的实现
- shell的case语句
- 手机测试android程序显示waiting for debugger 解决办法
- GfMath
- Android 内存溢出解决方案(OOM) 整理总结
- 有关map压入对象后,对象的数据成员发生改变的问题
- UvaLive-5902-Movie collection
- hdu 2151 Worm
- linux kernel经典参考书籍
- 实现并打印小于9的任意整数的n*n乘法表
- 对象数组与构造函数
- 一个可以重用的线程安全生产者消费者队列类