1.32位環境下html
#include <stdio.h> #include <iostream> #include <cstring> using namespace std; int main() { char t1[] = "ab\0cd"; char t2[6] = "abcd\0"; int t3[4] = {'0', 0, '\0'}; printf("%d\n",sizeof(t1)); printf("%d\n",sizeof(t2)); printf("%d\n",sizeof(t3)); printf("%d\n",strlen((char*)t3)); return 0; }
輸出:ios
6 6 16 1
解析:http://blog.csdn.net/chenjin_zhong/article/details/6097984面試
http://www.cnblogs.com/carekee/articles/1630789.html(這篇文章講sizeof和strlen的區別講得很好)
算法
http://blog.csdn.net/ce123_zhouwei/article/details/6971544(這篇文章講大端和小端規則講得很好,挺好的博客)
vim
#include <stdio.h> #include <iostream> #include <cstring> #include <bitset> using namespace std; int main() { char t1[] = "ab\0cd"; char t2[6] = "abcd\0"; int t3[4] = {'0', 0, '\0'}; printf("%d\n",sizeof(t1)); printf("%d\n",sizeof(t2)); printf("%d\n",sizeof(t3)); printf("%d\n",strlen((char*)t3)); cout << bitset<32>(t3[0]) << endl; cout << bitset<32>(t3[1]) << endl; cout << bitset<32>(t3[2]) << endl; cout << bitset<32>(t3[3]) << endl; char* ct3 = (char*)t3; cout << bitset<8>(ct3[0]) << endl; cout << bitset<8>(ct3[1]) << endl; cout << bitset<8>(ct3[2]) << endl; cout << bitset<8>(ct3[3]) << endl; return 0; }
2.冒泡排序的算法的複雜度?windows
參考:http://zh.wikipedia.org/wiki/%E6%8E%92%E5%BA%8F%E7%AE%97%E6%B3%95函數
3.C++的friend有什麼缺點spa
參考http://blog.csdn.net/adriano119/article/details/5914443.net
http://www.cnblogs.com/BeyondAnyTime/archive/2012/06/04/2535305.html (挺不錯的博客)code
4.填空聲明一個int類型的常引用變量i:_________=5;
const int& i = 5;
5.int i = 3, j = 2, k = 8;
k*=i-j++;
求j和k。
3 8
http://www.slyar.com/blog/c-operator-priority.html (C語言運算符優先級)
6.intel x86體系。
#include <stdio.h> #include <iostream> #include <cstring> #include <bitset> using namespace std; union { int i; char x[2]; }a; int main() { a.x[0] = 5; a.x[1] = 2; printf("%d\n", a.i); return 0; }
輸出:
517
解析:很簡單,只要知道union是將全部成員按照低地址存放還有大端和小端規則就好了。
http://blog.csdn.net/masefee/article/details/4160211
6.typedef和#define的用法和區別,應該如何選擇?
參考:http://www.cnblogs.com/kerwinshaw/archive/2009/02/02/1382428.html
7.析構函數有什麼做用,可否被重載?
參考:http://jaden.blog.51cto.com/1549175/324480
8.STL的vector、list的做用和區別?
參考:http://www.cppblog.com/Lee7/archive/2008/09/29/63035.html
http://blog.csdn.net/morewindows/article/details/6950917 (講STL挺好的博客)
9.純虛函數是什麼,作什麼用的?
參考:http://blog.csdn.net/Hackbuteer1/article/details/7558868 (有不少面試題的博客)
10.改錯題,主要考字符串的知識:fgets,snprintf,strcmp,strchar,strncpy
參考自:http://blog.csdn.net/kenby/article/details/3284290
http://blog.csdn.net/xuefu2008/article/details/4662534
http://blog.csdn.net/sky2098/article/details/1530433
http://blog.csdn.net/nabber/article/details/2212891
11.解析xml,仍是要用到字符串的知識。
12.動態規劃題(待補充)