码迷,mamicode.com
首页 >  
搜索关键字:unsigned    ( 4409个结果)
统计整数n的二进制表示中1的个数
(1)逐位判断(位运算) int counter_ones(unsigned n) { int counter = 0; While (n) { counter += n&1; n >>=1; } return counter; } (2)一个整型不为0,那么二进制表示时,至少包含一位1。如果整数减去1,那么最右边的1变成0,而该1后面的0变成1,其余位不变。将原来...
分类:其他好文   时间:2015-03-16 14:39:40    阅读次数:164
191. Number of 1 Bits Leetcode Python
Write a function that takes an unsigned integer and returns the number of ’1' bits it has (also known as the Hamming weight). For example, the 32-bit integer ’11' has binary representation 00000000...
分类:编程语言   时间:2015-03-16 12:57:41    阅读次数:180
iOS获取当前时间
- (void)time{     NSDate *now=[NSDate date];     NSCalendar *cal=[NSCalendar currentCalendar];     unsigned int time=NSCalendarUnitYear|NSCalendarUnitMonth|NSCalendarUnitDay|NSCalendarUnitH...
分类:移动开发   时间:2015-03-16 11:01:57    阅读次数:142
tasklet、工作队列和共享队列
tasklet(小任务): tasklet在很多方面类似内核定时器:他们始终在中断期间运行,始终会在调度他们的同一CPU上运行,而且都接收一个unsigned long参数。不同的是,不能要求tasklet在某个给定的时间执行,调度一个tasklet,表明我们只是希望内核选择某个其后的时间来执行给定的函..
分类:其他好文   时间:2015-03-16 06:27:49    阅读次数:412
HDU 5187
超简单的公式题(2^n-2)。不过,要过可不容易,因为会爆64位,所以,可以使用快速乘法。#include #include #include #define LL unsigned __int64using namespace std;LL n,p;LL mul(LL x,LL m,LL p)//...
分类:其他好文   时间:2015-03-15 22:44:33    阅读次数:132
MD5加密
iOS字符串加密至MD5 1 #import 2 3 + (NSString *) md5:(NSString *)str 4 { 5 const char *cStr = [str UTF8String]; 6 unsigned char result[16]; 7 ...
分类:其他好文   时间:2015-03-15 21:08:53    阅读次数:97
LeetCode Number of 1 Bits
1.题目Write a function that takes an unsigned integer and returns the number of ’1' bits it has (also known as the Hamming weight).For example, the 32-bit integer ’11' has binary representation 00000000...
分类:其他好文   时间:2015-03-15 19:53:10    阅读次数:92
Sizeof与Strlen的区别与联系
一、sizeof sizeof(...)是运算符,在头文件中typedef为unsigned int,其值在编译时即计算好了,参数可以是数组、指针、类型、对象、函数等。它的功能是:获得保证能容纳实现所建立的最大对象的字节大小。由于在编译时计算,因此sizeof不能用来返回动态分配的内存空间的大小。实...
分类:其他好文   时间:2015-03-15 19:33:58    阅读次数:151
四则续
1 #include 2 #include 3 #include 4 #include 5 #include 6 using namespace std; 7 8 9 10 int main(void) 11 { 12 srand((unsigned)ti...
分类:其他好文   时间:2015-03-15 16:41:50    阅读次数:194
蓝桥杯 基础练习 10进制转16进制
#include?<iostream> #include?"stdio.h" #include?"stdlib.h" #include?"memory.h" using?namespace?std; int?main(int?argc,?char?*argv[]) { unsigned?int?num?; cin?>>?num; int?tmp[999...
分类:其他好文   时间:2015-03-15 14:01:46    阅读次数:151
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!