问题:#
0027
 In C program,  at runtime,  
    * auto variables are stored in? 
    * static variables are stored in? 
    * function parameters are stored in?
 
 
问题:#
0028
 The statement "extern int x;" is a ____?
 
 
问题:#
0029
 What's the difference between buffered I/O and unbuffered I/O?
 
问题:#
0030
 class CDemo {
  public:
    CDemo(const char *str);
    ~CDemo();
  private:
    char name[20];
};
CDemo::CDemo(const char* str) {
    strcpy(name,str);
    cout < <"cout:Construction called for " < <name < <endl;
}
CDemo::~CDemo() {
   cout < <"cout:Destruction called for " < <name < <endl;
   printf(" printf:Destruction called for %s\n",name);
}
static CDemo GlobleObject("globeobject"); 
void main() {
  CDemo LocalObjectInMain("localobjectinmain");
  CDemo * pHeapObjectInMain=new CDemo("heapobjectinmain");
  CDemo *pHeapObjectInFunc=new CDemo("heapobjectinfunc");
  static CDemo StaticObject="staticobject";
} 
这里globeobject的析构并没有被显示出来,为什么呢? 
 
问题:#
0031
 Is following code correct? Why?
const char *s = "abcdefg";
s++;
 
问题:#
0032
 Is there any problem in following code?
int *p= new int[10];
delete p;
 
问题:#
0033
 struct st1 {
  char p1;
  char p3;
  short p2;
  int p4;
};
struct st2 {
  char p1;
  short p2;
  char p3;
  int p4;
};
What's the value of sizeof(st1) and sizeof(st2)?
 
问题:#
0034
 Is there any problem of bellow code piece?
//代码1
int A() {
  int test=10;
  return test;
}
int main() {
  int a=A();
  printf("%d\n",a);
  return 0;
} 
//代码2
char* A() {
  char p[]="hello world";
  return p;
}
int main() {
  char *str=NULL;
  str=A();
  printf("%s",str);
} 
 
问题:#
0035
 Is there any problem in below code?
#include <string>
#include <iostream>
void println_cstr(const char *text){
    std::cout<<text<<std::endl;
}
void println_string(const std::string &text){
    std::cout<<text<<std::endl;
}
int main(int argc, char **argv){
    const char *s_cstr = "This is a C string";
    std::string s_cpp("This is a C++ string");
    println_cstr(s_cpp);
    println_string(s_cstr);
    return 0;
}
 
问题:#
0036
问题:#
0037
 把二元查找树转变成排序的双向链表
输入一棵二元查找树,将该二元查找树转换成一个排序的双向链表。
要求不能创建任何新的结点,只调整指针的指向。
   
  10
  / \
 6 14
 / \ / \
4 8 12 16
   
 转换成双向链表
4=6=8=10=12=14=16。
   
 二元查找树节点的数据结构如下:
 struct BSTreeNode
{
  int m_nValue; // value of node
  BSTreeNode *m_pLeft; // left child of node
  BSTreeNode *m_pRight; // right child of node
};
 
问题:#
0038
 设计包含min函数的栈。
定义栈的数据结构,要求添加一个min函数,能够得到栈的最小元素。
要求函数min、push以及pop的时间复杂度都是O(1)。
 
问题:#
0039
 求子数组的最大和
输入一个整形数组,数组里有正数也有负数。
数组中连续的一个或多个整数组成一个子数组,每个子数组都有一个和。
求所有子数组的和的最大值。要求时间复杂度为O(n)。
例如输入的数组为1, -2, 3, 10, -4, 7, 2, -5,和最大的子数组为3, 10, -4, 7, 2,
因此输出为该子数组的和18。