(原文地址:http://blog.csdn.net/videosender/article/details/3137869)收集了一些我去微软 IBM google 笔试 面试的比较好的题目。大家可以练习一下,全都是c语言题目。1. 写一个宏toStr,把一个宏定义的符号变为对应的宏定义内容的字符串。比如#define NAME jackprintf("NAME is %s\n", toStr(NAME));会输出NAME is jack。2. 接着第一题,扩展一下,写个宏printValue,实现上面的功能。即: printValue(NAME);就会输出 NAME i Read More
posted @ 2013-03-10 22:21 knull Views(320) Comments(3) Diggs(0)
将数组进行循环左移位的代码实现,杂技算法,确实很杂技:#include <stdio.h>#include <stdlib.h>#define swap(a,b) {int temp = (a); (a) = (b); (b) = temp;}void rotate(int a[], int n, int m){ int i, len, p = 0, r = n - 1; while(1) { len = 1 + r - p; if(2 * m == len) { for(i = 0; i < m; ++i) { swap(a[p + i], a[p + m + Read More
posted @ 2012-12-18 03:16 knull Views(253) Comments(0) Diggs(0)
#ifndef BINARY_TREE#define BINARY_TREE#include <iostream>#include <stdio.h>#include <stack>using namespace std;class binaryTree{private: struct btNode { char data; btNode *left, *right; btNode(char c):data(c){} }; btNode *root; int size; //非递归后序遍历辅助数据的类型定义 s... Read More
posted @ 2012-12-14 19:50 knull Views(194) Comments(0) Diggs(0)
测试用例为两千万的int数组,使用随机数生成器生成整个数组的数值,测试结果为:堆排序14.8秒;qsort库函数6.4秒;归并排序4.4秒;快速排序版本1为2.7秒;快速排序版本2为2.7秒;二进制快速排序为4.8秒;基数排序为0.95秒,大比分领先于其他常见排序算法。附:测试代码如下(gcc -O3 test.c -o test.exe)#include <stdio.h>#include <stdlib.h>#include <time.h>#include <limits.h>#include <string.h>#includ Read More
posted @ 2012-12-11 21:45 knull Views(616) Comments(0) Diggs(0)
cpp's so bloody imbalance...felt so good when coding withcpp after months of coding with c...stl, so imbalance...but i dislike class. Read More
posted @ 2012-11-27 00:48 knull Views(101) Comments(0) Diggs(0)