首先我们来看看 (int) 强制类型转换:
#include <stdio.h> #include <stdlib.h> int main(){ int a = (int)(-1.9); int b = (int)(1.9); printf("%d\n%d\n", a, b); return 0; }
int func(float x) { if(x > 0.0) return (int)(x + 0.5); else return (int)(x - 0.5); }
原文地址:http://blog.csdn.net/ironyoung/article/details/40918153