amazon笔试题

来源:互联网 发布:poi数据 编辑:程序博客网 时间:2024/04/30 11:14
1.判断一年是否为闰年的方法
2.非递归实现exists方法

template <class T>
class BinaryTree{
protected:
    T* _data;
    BinaryTree<T> * _left;
    BinaryTree<T> * _right;
};

template <class T>
class BST:public BinaryTree<T>{
public:
    virtual bool exists(const T& item> const;
};

3.找到下面的bugs
#include<stdio.h>
#include<malloc.h>

void foo(int a ,char*b)
{
    b=(char *)malloc(64);
    snprintf(b,"you are %d years old!/n",a);
}

int main (void)
{
    char *f;
    foo(23,f);
    printf("%s/n",b);
}

4.Design a subway traffic control system.What objects/classes/modules would you best use for this 

purpose?Please draw diagrams and write up class definitions to better illustrate your 

design.Write anything additional to clarify your design.
原创粉丝点击