SAP笔试题

来源:互联网 发布:lms软件噪音分析 编辑:程序博客网 时间:2024/06/03 12:47
发信人: skysnow (王生洪), 信区: Job
标 题: SAP笔试题
发信站: 日月光华 (2004031819:33:15 星期四), 站内信件
 
1.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 type, int n>const type *find1(const type *& array, const type & x)
{
    const type * p = array;
    for(int i = 0; i < n; i++)
    {
        if(*p == x)
        {
            return p;
        }
        ++p;
    }
    return 0;
}
 
2. Assume you have a class like
class erp
{
    HR* m_hr;
    FI* m_fi;
public:
    erp()
    {
        m_hr = new HR();
        m_fi = new FI();
    }
    ~erp()
    {
    }
};
if "new FI()" failed in the constructor, how can you detect this problem and release the properly allocated member pointer m_hr?
C++里面不到万不得已别用TRY-CATCH,用 
    
  erp()   
  {   
  auto_ptr<HR>   auto_hr (new   HR());   
  auto_ptr<FI>   auto_fi (new   FI());   
  m_hr   =   auto_hr.release();   
  m_fi   =   auto_fi.release();   
    
  }   
3. Check the class and variable definition below:
#include <iostream>
#include <complex>
using namespace std;
class Base
{
public:
    Base() { cout<<"Base-ctor"<<endl; }
    ~Base() { cout<<"Base-dtor"<<endl; }
    virtual void f(int) { cout<<"Base::f(int)"<<endl; }
    virtual void f(double) {cout<<"Base::f(double)"<<endl; }
    virtual void g(int i = 10) {cout<<"Base::g()"<<i<<endl; }
};
class Derived: public Base
{
public:
    Derived() { cout<<"Derived-ctor"<<endl; }
    ~Derived() { cout<<"Derived-dtor"<<endl; }
    void f(complex<double>) { cout<<"Derived::f(complex)"<<endl; }
    virtual void g(int i = 20) {cout<<"Derived::g()"<<i<<endl; }
};
Base b;
Derived d;
Base* pb = new Derived;
Select the correct one from the four choices:
Cout<<sizeof(Base)<<endl;
A. 4    B.32    C.20    D.Platform-dependent
Ad?
Cout<<sizeof(Derived)<<endl;
A. 4    B.8 C.36    D.Platform-dependent
A?d?
pb->f(1.0);
A.Derived::f(complex)   B.Base::f(double)
B注意是base的指针,所以没有隐藏规则
pb->g();
A.Base::g() 10      B.Base::g() 20
C.Derived::g() 10   D.Derived::g() 20
c
4.Implement the simplest singleton pattern(initialize if if necessary).
class singleton{
private:
    static singleton *one;
    singleton(){}
    ~singleton(){
    }
public:
    static singleton * instance();
 
};
 
singleton * singleton::instance()
{
    if(one == NULL)
    {
       one = new singleton;
    }
 
       return one;
}
singleton *singleton::one = NULL;
5.Name three sort algorithms you are familiar with. Write out the correct order by the average time complexity.
Quick sort   merge sort heap sort           bubble sort
6.Write code to sort a duplex direction linklist. The node T has overridden the comparision operators
双向链表,重写==运算符
还有四道,不写了
发信人: jiazhang (张佳), 信区: job
标 题: 做点好事
发信站: 饮水思源 (2004111120:12:19 星期四), 站内信件
 
SAP笔试题
 
1 两个人轮流拿10个硬币,每次可拿1,2,4个,拿到最后一个的为输,问有无必胜条
件?
答:后拿者赢
还剩1个赢1-4-7而先拿的一次根本不能拿3
2 有1000个表,每个表有若干个item,每个item形式为(x,y),寻找这些表中overlapp
ed的item
 
3 用一串节点存放N个数据,每个节点可放k个数据,其中包含额外的b个数据,问k为多少最能节省存储空间(假设N/(k-b)mod1=1/2)
 
4 一个链表排序程序,补足其中一些丢失的语句(排序中不用额外的存储空间)
 
5 一篇英文,将打乱的各段排序并写个总结,大意是吹嘘SAP如何的好
 
6 两个仓库的进货,出货和仓库间的货物转移交易的流水帐,写出每次交易的货物数,
单价,交易后仓库中的货物数和amount(货物数*单价)
发信人: jianliu (剑流~穷人什么都要会), 信区: job
标 题: SAP题目
发信站: 饮水思源 (2004111120:17:51 星期四), 站内信件
 
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
先拿必输
2.the UI specialist Dafna found a problem that some of the Items on the marketing document form overlapped with each other. because this form was implemented by diffirent developers and they didn't care the particular appearance of one item. Product manager Todav decided to write one small checking tool to generate the overlapped items on all forms. He called in his guys to discuss about it. 
Suppose the input is the integer coordinates (x,y) od the items (all rectangles) on one form. Construct an efficient method to find out the overlapped items. 
Hint: The most direct way to do so is comparing each items with the others, Given 1000 forms. each with 100-1000items on average. the O(n2) algorithm is costly. Some guru suggested that one O(n) method could help only if 6.5 kilobytes extra storage is available. One elite argued that he could cut down the number to 1%,It's now your turn to describe the idea. write out the pseudocodes, verify his algorithm and propose more advanced optimization if possible.
1000个表,每个表有若干个item,每个item形式为(x,y),寻找这些表中overlappeditem ,要求时间复杂度为on
3 in a file system ,data need not be sequentially located in physical blocks, We use a number of tables storing nodes information. Suppose now we use a fixed node size of variable-length n,it takes [n/(k-b)] nodes to store this item.(Here b is a constant, signifying that b words of each node contain control information, such as a link to the next node).If the average length n of an Item is N, what choice of k minimizes the average amount of storage space required?
(Assume that the average value of (n/(k-b)) mod 1 is equal to 1/2 ,for any fixed k ,as n varies)
用一串节点存放N个数据,每个节点可放k个数据,其中包含额外的b个数据,问k为多
少最能节省存储空间(假设N/(k-b)mod1=1/2
发信人: SAP (Crespo), 信区: job
标 题: 求M:)
发信站: 饮水思源 (2004111413:12:01 星期天)
 
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才能赢,我先抽得话不可能达到这几个数,很显然,只能让对
方先抽,也即是先抽的人输
发信人: tomgang (linggang), 信区: job
标 题: SAP面试
发信站: 饮水思源 (2004121318:43:35 星期一), 站内信件
 
1.extern "C" {}
 
2. _std_afx
3. C++为何强制类型
新的转型运算子比较受欢迎。它们更容易在程序代码中被识别出来(不论是对人类或是对诸如grep 等工具而言),而且愈是缩小范围地指定各种转型运算子的目标,编译器愈有可能诊断出错误的运用。
4. static cast
   Dynamic cast
   Const cast
const_cast
用来将对象或指针的常数性(constness)转型掉,我将在条款21验证这个主题。
dynamic_cast
用来执行「安全的向下转型动作(safe downcasting)」,这是条款39 的主题。
reinterpret_cast
的转型结果取决于编译器例如在函式指标型别之间做转型动作。你大概不常需要用到reinterpret_cast。本书完全没有用到它。
static_cast
是个「杂物袋」:没有其它适当的转型运算子可用时,就用这个。它最接近传统的C 转型动作。
 
5. C里面的函数堆栈同C++的函数堆栈的区别
6. DB2的那个端口
7、SQL server 扩展存储过程
8、 Class A {}的内存镜像
9. rr serializable 怎么实现?区别?
10、VC 里面的异常机制要打开哪个选项?
11、Windows的COPY ON SITE 是怎么实现的
12、http协议的
    keep alive 作用
13、Process in linux, minix,的不同
14、数据库里的INSTANCE
15、C#调用win32的API是如何实现的?
16、数据库是怎样实现INDEX的
17、数据库DBMS设计时需要考虑的问题
18、ISOLATION LEVEL? 是如何实现的
发信人: liangfzh (liangfzh), 信区: job
标 题: SAP笔试(技术部分)--2005.11.23
发信站: 饮水思源 (2005112323:33:02 星期三)
 
Prerequisite Notice:
Answers are preferred in English;
Test time is 60 minutes;
Finish more than one question.
 
 
1.Give an example of implementing a Stack in the template way(only template class declaration without detail definition and realization)
template<class type> class stack {
private:
    type *element;
    int top;
    int maxSize;
public:
    stack(int size = 10);
    stack(const type& other);
    ~stack();
    void push(const type &item);
    type pop();
    type getTop() const;
    bool isEmpty() const;
    bool isFull() const;
    void makeEmpty();
};
2.What's the difference between String and StringBuffer?
 
3.Which came the first, chicken or the egg?
 
4.In C++,there're four types of Casting Operators, please enumerate and explain
them especially the difference.
4种强制类型:static_cast, const_cast, dynamic_cast, reinterpret_cast
5.Let's say we have a database with 1 one-column table. It contains same records. Could you please give at least 1 solution to help us get records between line 5 and 7. No line number, row id or index etc.
 
6.What will be the output of the following codes?
 #include <iostream.h>
 #define DBL(x) x+x
 int main()
 {
    int a=3;
    int b=4;
    int c=DBL(a)*DBL(b);
    cout<<c<<endl;
    return 0;
   }
19
7.Please write a program to realize the model described in the figure. You should design your program as generic as possible so that we can enhance the model in the future easily without making too much change in your program.
 
Process1:X=A+B;
Process2:Y=C+D;
Process3:if E>=0
           Z=E;
Process4:if E<0
         Z=E/B;
 
大家第五题怎么做的?
发信人: ahnulxy (^_^我爱Java^_^), 信区: job
标 题: SAP(逻辑智力测试)--2005.11.23
发信站: 饮水思源 (2005112323:42:49 星期三)
 
晚上的笔试,有三部分,这是第二部分,呵呵,冒着险拿出来两张试卷。
智力测试部分共有 5道题目,其中三道比较容易我就不打上去了,把其中比较难的两道,
打出来,如果有时间我会全部打!   
 
3.Now is the excellent time to invest in the catering business. A survey conducted by Weddings magazine found that 70 percent of the magazine's readers want a catered wedding reception. An analysis of the catering industry, however, shows that the current number of caterers can serve only 55 percent of the weddings likely to occur each year.
 Which of the following, if true, would undermine the validity of the investment advice in the paragraph above?
 
A. The average wedding reception involves between 50 and 100 guests.
B. Approximately a quarter of all weddings take place without a reception.
C. approximately a quarter of all weddings and their associated receptions are
 paid for by the couples themselves.
D. Only half of all catered wedding reception include sit-down meals.
E. Only half of those who say they want a catered wedding reception actually h
as one.
 
5. Which of the following best completes the passage below?
 "Government" does exist as an independent entity defining policy. Instead the
re exists a group of democratically elected pragmatists sensitive to the elect
orate, who establish policies that will result in their own reelection. Theref
ore, if public policy is hostile to , day environmental concerns, it is not be
cause of govern-mental perversity but because elected officials believe that__
____.
A. Environmentalists would be extremely difficult to satisfy with any policy, 
however environmentally sound.
B. Environmental concerns are being accommodated as well as public funds permi
t.
C. The public is overly anxious about environmental deterioration.
D. The majority of voters vote for certain politicians because of those politi
cian’s idiosyncratic positions on policy issues.
E. The majority of voters do not strongly wish for a different policy.
 
大家讨论一下啊!呵呵。。。