我来我网
https://5come5.cn
 
您尚未 登录  注册 | 菠菜 | 软件站 | 音乐站 | 邮箱1 | 邮箱2 | 风格选择 | 更多 » 
 

本页主题: 一些笔试题目和整理的答案 显示签名 | 打印 | 加为IE收藏 | 收藏主题 | 上一主题 | 下一主题

墨水不黑



性别: 帅哥 状态: 该用户目前不在线
等级: 品行端正
发贴: 465
威望: 0
浮云: 1155
在线等级:
注册时间: 2006-11-23
最后登陆: 2014-03-09

5come5帮你背单词 [ pupil /'pju:pl/ n. 学生,小学生(眼睛的)瞳孔 ]


一些笔试题目和整理的答案

NO1
Below is usual way we find one element in an array
const int *find1(const int* array, int n, int x)
{
    const int* p = array;
    for(int i = 0; i < n; i++)
    {
        if(*p == x)
        {
            return p;
        }
        ++p;
    }
    return 0; }
In this case we have to bear the knowledge of value type "int", the size of array, even the existence of an array. Would you re-write it using template to eliminate all these dependencies?

template <class T>
const T *find1(const T* array, int n, T x)
{
    const T* p = array;
    for(int i = 0; i < n; i++)
    {
        if(*p == x)
        {
            return p;
        }
        ++p;
    }
    return 0; }

NO2

Give an example of implementing a Stack in the template way(only template class declaration without detail definition and realization)
template <class T>
class Stack
{
public:
      Stack(int = 10) ;
      ~Stack() { delete [] stackPtr ; }
      int push(const T&);
      int pop(T&) ; 
      int isEmpty()const { return top == -1 ; }
      int isFull() const { return top == size - 1 ; }
private:
      int size ;  // number of elements on Stack.
      int top ; 
      T* stackPtr ; 
} ;


NO3

Implement the simplest singleton pattern(initialize if necessary).
class Singleton {
public:
    static Singleton* Instance();
protected:
    Singleton();
private:
    static Singleton* _instance;
}

// Implementation
Singleton* Singleton::_instance = 0;

Singleton* Singleton::Instance() {
    if (_instance == 0) {
        _instance = new Singleton;
    }
    return _instance;
}



NO4

1.Jeff and Diamond like playing game of coins, One day they designed a new set of rules:
1)Totally 10 coins
2)One can take away 1,2or 4 coins at one time by turns
3)Who takes the last loses.
Given these rules Whether the winning status is pre-determined or not
解答: 1:从后面开始考虑,最后肯定要留1个才能保证自己赢
2:所以要设法让对方留下2,3,5个
3:也就是要自己取后留下1,4,6,7,8,9
4:如果自己取后留下6,对方取2个,与(3)矛盾,所以排除6
5:如果自己取后留下8,对方取4个,与(3)一样情况,所以也排除8
6:同样,9也不行,如果我抽后剩下9,对方抽2个,就反过来成对方抽剩成7个了,也与3)矛盾,所以也排除
7:所以很显然,我只能抽剩1,4,7
8:因为只能抽后剩1,4,7才能赢,我先抽得话不可能达到这几个数,很显然,只能让对
方先抽,也即是先抽的人输
顶端 Posted: 2007-09-24 10:39 | [楼 主]
mrhhsg



性别: 帅哥 状态: 该用户目前不在线
等级: 鹤立鸡群
家族: Banquet
发贴: 1129
威望: 1
浮云: 2914
在线等级:
注册时间: 2005-10-03
最后登陆: 2009-12-21

5come5帮你背单词 [ frog /frog/ n. 蛙 ]


楼主
解释下噻
看不懂
顶端 Posted: 2007-09-24 10:41 | [1 楼]
墨水不黑



性别: 帅哥 状态: 该用户目前不在线
等级: 品行端正
发贴: 465
威望: 0
浮云: 1155
在线等级:
注册时间: 2006-11-23
最后登陆: 2014-03-09

5come5帮你背单词 [ trap /træp/ n. 陷阱,诡计,圈套;vt. 设陷阱捕捉,使陷入困境 ]


Quote:
引用第1楼mrhhsg于2007-09-24 10:41发表的  :
楼主
解释下噻
看不懂

请你不要瓜要不要得。
顶端 Posted: 2007-09-24 10:50 | [2 楼]
lichundong



性别: 帅哥 状态: 该用户目前不在线
头衔: 从来不灌水,只发精华帖
等级: 荣誉会员
发贴: 27189
威望: 3
浮云: 0
在线等级:
注册时间: 2006-04-30
最后登陆: 2015-08-30

5come5帮你背单词 [ redundant /ri'dΛndənt/ a. 多余的,冗余的 ]


没搞懂!
顶端 Posted: 2007-09-24 10:51 | [3 楼]
mrhhsg



性别: 帅哥 状态: 该用户目前不在线
等级: 鹤立鸡群
家族: Banquet
发贴: 1129
威望: 1
浮云: 2914
在线等级:
注册时间: 2005-10-03
最后登陆: 2009-12-21

5come5帮你背单词 [ lose /lu:z/ vt. 丢失,失去,迷路,使迷惑,输掉;vi. 亏本,失败,输掉 ]


Quote:
引用第2楼墨水不黑于2007-09-24 10:50发表的  :

请你不要瓜要不要得。

你娃灌水
顶端 Posted: 2007-09-24 10:53 | [4 楼]
墨水不黑



性别: 帅哥 状态: 该用户目前不在线
等级: 品行端正
发贴: 465
威望: 0
浮云: 1155
在线等级:
注册时间: 2006-11-23
最后登陆: 2014-03-09

5come5帮你背单词 [ garment /'ga:mənt/ n. 衣服,外衣 ]


Quote:
引用第4楼mrhhsg于2007-09-24 10:53发表的  :

你娃灌水

召唤版主来扣你浮云,你娃纯水了。
顶端 Posted: 2007-09-24 10:55 | [5 楼]
mrhhsg



性别: 帅哥 状态: 该用户目前不在线
等级: 鹤立鸡群
家族: Banquet
发贴: 1129
威望: 1
浮云: 2914
在线等级:
注册时间: 2005-10-03
最后登陆: 2009-12-21

5come5帮你背单词 [ shatter /'ætə/ vt. 使粉碎,使破灭;vi. 破碎,粉碎 ]


Quote:
引用第5楼墨水不黑于2007-09-24 10:55发表的  :

召唤版主来扣你浮云,你娃纯水了。

我现在才发现
你和冒菜不冒的名字简直是异曲同工啊
顶端 Posted: 2007-09-24 11:01 | [6 楼]
墨水不黑



性别: 帅哥 状态: 该用户目前不在线
等级: 品行端正
发贴: 465
威望: 0
浮云: 1155
在线等级:
注册时间: 2006-11-23
最后登陆: 2014-03-09

5come5帮你背单词 [ break /breik/ vt. 打破,破碎,中断,中止,违反(法律、规定等);vi. 破,断裂;n. 中断,间歇 ]


Quote:
引用第6楼mrhhsg于2007-09-24 11:01发表的  :

我现在才发现
你和冒菜不冒的名字简直是异曲同工啊

终于被你发现了
顶端 Posted: 2007-09-24 11:43 | [7 楼]
fan



性别: 帅哥 状态: 该用户目前不在线
头衔: when u confuse,fuck.
等级: 荣誉会员
家族: fans
发贴: 10499
威望: 7
浮云: 415
在线等级:
注册时间: 2005-09-27
最后登陆: 2018-04-03

5come5帮你背单词 [ enterprise /'entəpraiz/ n. 企(事)业单位,事业心,进取心,冒险精神 ]


你们啊  追星  追到导员那儿去了、。。。
顶端 Posted: 2007-09-24 12:06 | [8 楼]
梦幻小猪



性别: 帅哥 状态: 该用户目前不在线
等级: 栋梁之材
发贴: 730
威望: 0
浮云: 1157
在线等级:
注册时间: 2006-04-01
最后登陆: 2009-05-07

5come5帮你背单词 [ provision /prə'vi3ən/ a,供应,供应品,预备,准备,规定,条款 ]


什么意思?
顶端 Posted: 2007-09-24 13:11 | [9 楼]
我来我网·5come5 Forum » 工作交流

Total 0.015271(s) query 5, Time now is:09-18 15:23, Gzip enabled
Powered by PHPWind v5.3, Localized by 5come5 Tech Team, 黔ICP备16009856号