摘要: 1.假定x=500,求下面函数的返回值__6_ 。12345678910int fun(int x){int countx = 0;while (x){countx++;x = x & (x – 1);}return countx;}解析:x&(x-1) 就是从右到左遇到的第一个1后面的(包括1)全... 阅读全文
posted @ 2015-08-13 16:33 wy1290939507 阅读(448) 评论(0) 推荐(0) 编辑
摘要: 1.小数值1.5625的二进制表示是? 1.10012.在二进制数据中,小数点向右移一位,则数据: 乘以2解析:(1)二进制转换为十进制:1101.0101=2^3+2^2+2^0+2^-2+2^-4=13.3125;(2)十进制小数转化为二进制:0.3125*2=0.625, 小数点后第一位为0... 阅读全文
posted @ 2015-08-13 16:22 wy1290939507 阅读(177) 评论(0) 推荐(0) 编辑
摘要: 1.ARM、MIPS、SPARC、CISC中属于复杂指令集的是CISC;其他都是精简指令集。2.IP数据报头采用()字节序,在此字节序下从低地址到高地址0x1234的表示形式为 (C) 。big_endian,0x12 0x34 0 0little_endian,0x34 0x12 0 0big_e... 阅读全文
posted @ 2015-08-13 15:49 wy1290939507 阅读(263) 评论(0) 推荐(0) 编辑
摘要: 1.一个从大到小的数组,按从小到大的顺序排序,哪种排序方法最快?(最坏情况)(1)冒泡排序:1+2+...n-1=O(n^2);(2)快速排序:每次partion都需要比较k-1次,才能将“第一个”数字移动到“末端”。需要进行n-1次partion才能完成排序。所以最坏情况下比较次数仍然是1+2+.... 阅读全文
posted @ 2015-08-13 11:03 wy1290939507 阅读(481) 评论(0) 推荐(0) 编辑
摘要: 1. qsort:void qsort(void *base,int nelem,int width,int (*fcmp)(const void *,const void *));头文件:#include参数: 1 待排序数组首地址2 数组中待排序元素数量3 各元素的占用空间大小4 指向函数的指针... 阅读全文
posted @ 2015-08-12 09:44 wy1290939507 阅读(154) 评论(0) 推荐(0) 编辑
摘要: int GetUglyNumber(int index){ if(index<=0) return 0; int *pUglyNumbers=new int[index]; pUglyNumbers[0]=1; int nextUglyIndex=1; i... 阅读全文
posted @ 2015-08-11 20:20 wy1290939507 阅读(116) 评论(0) 推荐(0) 编辑
摘要: 题目:输入一个正整数数组,把数组中所有的数拼接成一个整数,输出最小的整数。思路:设计一种新的比较规则来排序一个数组,证明这个比较规则有效。(1)两个数m,n,如果mn#include#include //qsort需要的头文件const int g_MaxNumberLength=10;cha... 阅读全文
posted @ 2015-08-11 14:02 wy1290939507 阅读(174) 评论(0) 推荐(0) 编辑
摘要: 思路:假设数字为21345,用strN字符串来存储。把数字分为2段,一段是1~1345,另一段是1346~21345.(1)1345~21345中,万位上出现1的数字在10000~19999中,有10^4个。如果n的长度为length,则共有10^(length-1)次。(2)如果首位数字等于1,比... 阅读全文
posted @ 2015-08-11 13:08 wy1290939507 阅读(1282) 评论(0) 推荐(0) 编辑
摘要: 排序方法平均时间最坏情况辅助存储简单排序O(n^2)O(n^2)O(1)快速排序O(nlogn)O(n^2)O(logn)堆排序O(nlogn)O(nlogn)O(1)归并排序O(nlogn)O(nlogn)O(n)基数排序O(d(n+rd))O(d(n+rd))O(rd)1.简单排序 直接插入排序... 阅读全文
posted @ 2015-08-10 22:45 wy1290939507 阅读(636) 评论(0) 推荐(0) 编辑
摘要: 参考文章:http://www.cnblogs.com/txw1958/archive/2012/07/12/scrapy_installation_introduce.html一、 Scrapy简介Scrapy is a fast high-level screen scraping and we... 阅读全文
posted @ 2015-07-29 13:34 wy1290939507 阅读(158) 评论(1) 推荐(0) 编辑