Number of 1 Bits2015.4.17 05:48Write a function that takes an unsigned integer and returns the number of ’1' bits it has (also known as theHamming wei...
分类:
其他好文 时间:
2015-04-17 07:10:13
阅读次数:
120
Reverse Bits2015.4.17 05:42Reverse bits of a given 32 bits unsigned integer.For example, given input 43261596 (represented in binary as000000101001010...
分类:
其他好文 时间:
2015-04-17 07:09:09
阅读次数:
108
习题2.1/*各种类型在本机所在字长 */ #includeint main(){ std::coutint main(){ unsigned u=10,u2=42; std::coutint main(){ int month=9,day=7; std::coutint main()...
分类:
编程语言 时间:
2015-04-17 01:01:43
阅读次数:
280
#include #include knuth(int n, int m){ srand((unsigned int)time(0)); for (int i = 0; i < n; i++) { if (rand()%(n-i)<m ) { ...
分类:
编程语言 时间:
2015-04-16 23:33:54
阅读次数:
174
函数原型#include
long int random(void);
void srandom(unsigned int seed);
srandom
该函数传递下来的参数作为种子,用于random返回随机数。如果种子不变,那么每次random产生的随机序列也是一样的。如果不给srandom传递参数,则种子默认为1。
random
使用种子产生随机序列,随机数的范围是0...
分类:
其他好文 时间:
2015-04-16 15:53:02
阅读次数:
86
Ptr=NULL; //NULL在文件stdio.h中定义过。 Ptr=(unsigned int *)malloc(N*sizeof(int)); //注意一定是要开辟N个int型的字节长度,不然编译会出错。 //printf("%ld\n",Ptr); for(i=0;i { *(Pt...
分类:
其他好文 时间:
2015-04-16 01:30:25
阅读次数:
262
一.基于时间片轮转调度代码的解读 代码结构主要由三个文件组成: 1.mypcb.h 2.myinterrupt.c 3.mymain.c1.进程控制块(mypcb.h)/* CPU-specific state of this task */struct Thread{ unsigned...
分类:
系统相关 时间:
2015-04-15 23:10:11
阅读次数:
178
Counting bits set (naive way)unsigned int v; // count the number of bits set in vunsigned int c; // c accumulates the total bits set in vfor (c = 0; v...
分类:
其他好文 时间:
2015-04-15 21:07:12
阅读次数:
256
/*
通过输入年月日,计算出这一天是星期几,计算这一天是这一年的多少天,判断这一年是否为闰年
*/
#include
using namespace std;
struct time
{
int year;
int month;
int day;
unsigned int weekday;
};
void initialtime(time & t);//输入初始化时...
分类:
编程语言 时间:
2015-04-15 09:42:13
阅读次数:
293
/** unsigned long nSampleRate, // 采样率,单位是bps* unsigned long nChannels, // 声道,1为单声道,2为双声道* unsigned long &samplesInput, ...
分类:
其他好文 时间:
2015-04-14 14:28:15
阅读次数:
129