04 2015 档案

摘要:1.sizeof和strlen的区别 1)sizeof操作符的结果类型是size_t,它在头文件中的typedef为unsigned int 类型。该类型保证能容纳实现所在建立的最大对象的字节大小 2)sizeof 是操作符,strlen是函数 3)sizeof是可以用类型做参数,strlen... 阅读全文
posted @ 2015-04-20 01:38 原声 阅读(96) 评论(0) 推荐(0)
摘要:有两个变量a,b,不用if ?: switch或其他判断语句找出两个中比较大的int max = ((a + b) + abs(a-b)) / 2给三个整数a,b,c函数实现取三个数的中间数,不可以使用sort,整数操作尽可能少1 inline int max(int a, int b) ( ret... 阅读全文
posted @ 2015-04-19 16:27 原声 阅读(133) 评论(0) 推荐(0)
摘要:#includeusing namespace std;int func(int x){ int count = 0; while(x){ count++; x = x & (x - 1); } return count;}int main(){ cout10011100001... 阅读全文
posted @ 2015-04-19 15:53 原声 阅读(107) 评论(0) 推荐(0)