浙江大华2011.10.10校园招聘会笔试题
1、
int count = 3; int main(void) {int i, sum, count = 2;for(i=0,sum=0; i<count; i+=2,count++){static int count = 4;count++;if(i%2 == 0){extern int count;count++;sum += count;}sum += count;}printf("%d %d\n",count, sum);return 0; }2、
void func(char str[50]) {printf("A %d B %d ",sizeof(str), strlen(str)); } int main(void) {char stra[] = "HelloWorld";char *strb = stra;printf("C %d D %d ",sizeof(stra), sizeof(strb++));func(++strb);printf("E %d F %d\n",strlen(stra), strlen(strb++));return 0; }printf("C %d D %d ",sizeof(stra),sizeof(strb++)); 中的sizeof(strb++)并不對sizeof函數中strb進行自增運算,只是簡單的求這個指針的大小,此時的strb指針還是指向stra。
3、
#include <vector> int func(std::vector<int>vec) {static int k = 2;std::vector<int>::reverse_iterator it;for(it = vec.rbegin(); it!=vec.rend(); ++it){k += *it%2==0? ++*it: (*it)++;}return k; } int main(void) {std::vector<int>vec;for(int i = 0; i<4; i++){vec.push_back(i);printf("%d ",func(vec));}return 0; }?4、
class Base { public:int m_a;Base(int a=2):m_a(a){printf("A %d ",m_a);}virtual ~Base(){printf("B %d ",m_a);} }; class Derived:public Base { public:Derived(int a=4):Base(a){printf("C %d ",m_a);}~Derived(){printf("D %d ",m_a);} }; int main(void) {Base *aa,bb;aa = new Derived;delete aa;return 0; }5、
class Base { public:int m_a,m_b;Base(int a = 2,int b = 5):m_a(a),m_b(b) { }int func_a(){return m_a - m_b;}virtual int func_b(){return m_a + m_b;} }; class Derived:public Base { public:Derived(int a = 4, int b = 7):Base(a, b) { }virtual int func_a(){return m_b + m_a;}int func_b(){return m_b - m_a;} }; int main(void) {Base *aa, *bb;aa = new Base(4, 7);bb = new Derived(3, 5);printf("%d %d %d %d\n",aa->func_a(), aa->func_b(), bb->func_a(), bb->func_b());delete aa;delete bb;return 0; }6、
struct SC {int a;int b;int c; }; struct SD {int a;int b;int c;int d; }; int main(void) {struct SC c1[] = {{3},{4},{5},{6}};struct SD *c2 = (struct SD*)c1 + 1;printf("%d %d %d %d\n",c2->a,c2->b,c2->c,c2->d);return 0; }7、
int func(int n) {int k = 1;if(n > 0){k += func(--n);printf("%d ", n);k += func(--n);}return k; }int main(void) {int a = 3;printf("%d\n",func(a));return 0; }答案:
1、? 4?? 20
2、 C 11 D 4 A 4 B 9 E 10 F 9
3、 3? 5? 10? 18
4、 A 2 A 4 C 4 D 4 B 4? B 2
5、 -3 11 -2 2
6、 0? 0? 5 ?0
7、? 0 ?1 ?2 ?0 ?9
編程題:
1、函數checkstr判斷一字符串是不是對稱的。其中msg為輸入的字符串,對稱返回0,不對稱返回-1,實現該函數。
int checkstr(const char *msg);
int checkstr(const char *msg) {int len = strlen(msg);int i, j;for(i = 0,j = len-1; i <= j; i++,j--){if(msg[i] != msg[j])break;}if(i>j)return 0;elsereturn -1; } 2、給出一個單向鏈表的頭指針,輸出該鏈表中倒數第K個節點的指針,鏈表的倒數第0個節點為鏈表的尾節點(尾節點的next成員為NULL)
typedef struct Node
{
???????? struct Node *next;
}NODE;
NODE* findnode(NODE *head,unsigned int k);
思路:在遍歷時維持兩個指針,第一個指針從鏈表的頭指針開始遍歷,在第k-1步之前,第二個指針p保持不動;
在第k-1步開始,第二個指針p也開始從鏈表的頭指針開始遍歷。由于兩個指針的距離保持在k-1,當第一個(走在前面的)指針pcur到達鏈表的尾結點時,第二個指針指針p正好是倒數第k個結點。
這種思路只需要遍歷鏈表一次。對于很長的鏈表,只需要把每個結點從硬盤導入到內存一次。因此這一方法的時間效率比較高。
簡答題:
1、簡述動態鏈接庫DLL和靜態鏈接庫lib的差別。
2、請簡述MFC中的窗口收到WM_PAINT消息是如何處理的,什么情況下會產生WM_PAINT消息。
3、請簡述Critical Section 、Mutex、Semaphore的功能和差別
4、簡述多線程程序對比單線程程序的優點和缺點。
總結
以上是生活随笔為你收集整理的浙江大华2011.10.10校园招聘会笔试题的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 淘宝2011.9.21校园招聘会笔试题
- 下一篇: 浙江绿盟科技2011.10.14校园招聘