一.簡答題.
1.避免死鎖的方法有哪些?
2.在Sybase資料庫中註冊使用者與資料庫使用者有什麼區別?
3.在MS SQL_Server 資料庫中通過什麼約束保證資料庫的`實體完整性
4.記憶體有哪幾種儲存組織結構.請分別加以說明
中的Wait() 和notify()方法使用時應注意些什麼?
6.使用者輸入一個整數.系統判斷,並輸出是負數還是非負數,請設計測試用例.
7.作業系統中的同步和互訴解決了什麼問題
中init
二.編寫類String 的建構函式,解構函式和賦值函式
已知類String 的原型為
class string
{
public:
string(const char *str=null);//普通建構函式
string(const string &other);//拷貝建構函式
---string(void);
string &operate=(const string &other);//賦值函式
private:
char * m-data;//用於儲存字串
};
請編寫string 的上述4個函式
三.有關記憶體的思考題
getmemory(char *p)
{ p=(char*)mallol(100);
}
void test(void)
{
char * str =null;
getmemory(str);
strcpy(str,”hello,world”);
printf(str);
}
請問執行Test函式會有什麼樣的結果
*getmemory(void)
{ char p[]=”hello world”;
return p;
}
void test(void)
{
char *str=null;
str=Getmemory();
printf(str);
}
請問執行Test 函式會有什麼樣的結果.
筆試題目二
問題:
Write a function to get the second maximum number in an integer array.(請寫程式返回一個數組中第2大的數)
int getsecond(int a [])
答案:
int getsecond(int a[],int nLength)
{
int nMax = -1000, nSec = 0;
for(int i = 0 ; i < nLength ; i ++ )
{
if(nMax < a[i])
{
nSec = nMax;
nMax = a[i];
}
else
{
if(a[i] > nSec)
nSec = a[i];
}
}
return nSec;
}