编译环境:myeclipse+cdt+MinGW,注意事项:
1.安装MySQL时,要选上安装开发组件
2.把MySQL安装目录的MySQL Server 5.0\lib\debug下面的两个文件libmysql.lib和libmysql.dll,复制到C++工程项目文件夹里
3.把M...... <阅读全文>
C++面试题 C++笔试题
一、选择题
1.下面各项不属于派生新类范畴的是(C )
A.吸收基类的成员
B.改造基类的成员
C.删除基类的成员
D.添加新成员
2.在派生新类的过程中,( D )
A....... <阅读全文>
#include<stdio.h>
main(){
int c[3][3]={1,2,3,4,5,6,7,8,9};
for(int i=0;i<3;i++)
for(int j=0;j<3;j++)
printf(“%ld\n”,&c[j]);
printf(“————...... <阅读全文>
例如,输入一个3,则 打印出
1 2 3
8 9 4
7 6 5
输入一个4,则 打印出
1 2 3 4
12 13 14 5
11 16 15 6
10 9 8 7
答案如下:
#include<stdio.h>
#include<conio.h>
#define N 10
void prin...... <阅读全文>
1、 关键字理解:const、static、volatile、sizeof、malloc/free、new/delete、extern、#ifndef/#endif、virtual、define、typedef、namespace等,重点是sizeof、virtual、const。
2、 关于sizeof结果,请注意...... <阅读全文>
1.什么是COM?你怎么理解COM?
答:Components Object Model(COM)是软件组件互相通信的一种方式。它是一种二进制和网络标准,允许任意两个组件互相通信,而不管它们是在什么计算机上运行(只要计算机是相连的),...... <阅读全文>
1. c++中指针的优缺点有哪些
答案:优点:
(1)提高程序的编译效率和执行速度。
(2)通过指针可使用主调函数和被调函数之间共享变量或数据结构,便于实现双向数据通讯。
(3)可以实现动态的存储分配。
(4)便于表...... <阅读全文>
1。给定下面的代码:
class Graph{
public:
Graph() { s_gCount++; }
virtual ~Graph() { s_gCount–;}
virtual int drawOut() = 0;
static int getTotalCount() { return s_gCount; }
protected:
int m_...... <阅读全文>
1. What’s overload function in C++?
2. A. What’s inline function in C++?
B. When would you use inline function?
C. Please write sample code.
3. Which of the following are legal? Fo...... <阅读全文>
C语言风格的代码:
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
const int M=10;
typedef int Type;
typedef struct Node{
Type data;
struct Node* next;
}Node;
void...... <阅读全文>
1. [0,1], random generator gives even distributed number (x). How to get a linear distributed series (y), such that the probability of 0 is 1, and the probability of 1 is 0. (that is, p(y) = 1-y...... <阅读全文>
211. Rabin Karp Algorithm
略。。。
212. Given a list of presentations with begin and end time that all need to use a conference room. We want to optimize the utilization of the room by all...... <阅读全文>
181. void reversePairsOfLinkList(Node*& head) {}
[] => []
[A,B] => [B, A]
[A, B, C] => [B, A, C]
[A, B, C, D, E, F, G] => [B, A, D, C, F, E, G]
见195题
182. You have to p...... <阅读全文>
151. 给你一串数字,让你写程序,把操作符(可以是任意多个 + – * / %)放进各个数字之间,同时还可以在任意位置放进括号,让这个算术表达式的值等于一个给定的数字。比如:给你 5 3 8 9 = 6你的程序应...... <阅读全文>
121. [Apple] You are given a deck containing n cards. While holding the deck:
1. Take the top card off the deck and set it on the table
2. Take the next card off the top and put it on the botto...... <阅读全文>
91. Given an int n, print all the numbers which are less than n and in the following pattern: 1,4,5,9,14… Write a recursive program.
看不懂…
92. How to sort a large collection of str...... <阅读全文>
61. [Google] 两个排序好的数组,求和最小的M个pair, 比如 A={1, 2, 4, 5, 6}, B={3, 5, 7, 9}
m=3那么Results就是(1, 3),(2, 3),(1, 5)
这个结构形成了一个行列有序的矩阵,这个题就类似于在行列有序的矩...... <阅读全文>
31. [Microsoft] 如何高效地用堆栈模拟队列.
使用两个stack, s1和s2
Push时,push到s1
Pop时,若s2非空,则从s2中pop, 若s2为空,则将s1的全部元素pop到s2中,再从s2中pop
分摊复杂度为O(1)
32. [Microsoft]...... <阅读全文>
1. 在linked list中找倒数第N个结点
2. 倒转linked list
3. 二叉树的结点有指向parent的指针,求最近公共祖先
4. 给一个数组,如何打印该数组成员构成集合的全部子集合.
5. 有两个字符串,一个是text,一个是com...... <阅读全文>
1. 一个系统里面有多个线程, 其中一个线程想终止另外一个线程, 该怎么实现.
2. 为什么要用virtual destructor
3. 什么是heap corruption
4. Semaphore VS Mutex
5. C++中的static, 怎么用,内存在哪里分配,等...... <阅读全文>
要求根据代码分析代码的功能:
unsigned int CountOne(unsigned int x){
x = (x & 0×55555555) + (x >> 1 & 0×55555555);
x = (x & 0×33333333) + (x >> 2 & 0...... <阅读全文>
1)sizeof相关系列问题, const相关系列问题
a. 对于 struct s{char a;int b} sizeof(s) = 8 因为内存对齐
b. 对于struct s{int a;char b} sizeof(s) = 5 这里不需要内存对齐,对齐只向上不向下,这种考得少
...... <阅读全文>
面试SE时,很多公司喜欢问到虚函数相关。宝宝有一次被问到,CObject类中的析构函数为什么是虚函数,不懂。后来上网查到了答案,特贴上来与大家分享
MFC类库中,CObject类的重要性不言自明的。在CObject的定义...... <阅读全文>
C、传统 C++
#include //设定插入点
#include //字符处理
#include //定义错误码
#include //浮点数处理
#include //文件输入/输出
#include //参数化输入...... <阅读全文>
开发环境
—->Turbo c
DOS时代c语言开发的经典工具,目前适合两类人使用:c语言beginner(尤其是学生一族),具有怀旧情节的专业人士:)
—->Visual C++ 6.0/7.0
稳定而强...... <阅读全文>
