欧美性猛交XXXX免费看蜜桃,成人网18免费韩国,亚洲国产成人精品区综合,欧美日韩一区二区三区高清不卡,亚洲综合一区二区精品久久

打開(kāi)APP
userphoto
未登錄

開(kāi)通VIP,暢享免費電子書(shū)等14項超值服

開(kāi)通VIP
最全的C\C 面試題解(2)
1. 以下三條輸出語(yǔ)句分別輸出什么?[C易]
char str1[] = "abc";
char str2[] = "abc";
const char str3[] = "abc";
const char str4[] = "abc";
const char* str5 = "abc";
const char* str6 = "abc";
cout << boolalpha << ( str1==str2 ) << endl; // 輸出什么?
cout << boolalpha << ( str3==str4 ) << endl; // 輸出什么?
cout << boolalpha << ( str5==str6 ) << endl; // 輸出什么?


2. 非C++內建型別 A 和 B,在哪幾種情況下B能隱式轉化為A?[C++中等試題]
答:
a. class B : public A { ……} // B公有繼承自A,可以是間接繼承的
b. class B { operator A( ); } // B實(shí)現了隱式轉化為A的轉化
c. class A { A( const B& ); } // A實(shí)現了non-explicit的參數為B(可以有其他帶默認值的參數)構造函數
d. A& operator= ( const A& ); // 賦值操作,雖不是正宗的隱式類(lèi)型轉換,但也可以勉強算一個(gè)

3. 以下代碼中的兩個(gè)sizeof用法有問(wèn)題嗎?[C易]
void UpperCase( char str[] ) // 將 str 中的小寫(xiě)字母轉換成大寫(xiě)字母
{
for( size_t i=0; i<sizeof(str)/sizeof(str[0]); ++i )
if( 'a'<=str[i] && str[i]<='z' )
str[i] -= ('a'-'A' );
}
char str[] = "aBcDe";
cout << "str字符長(cháng)度為: " << sizeof(str)/sizeof(str[0]) << endl;
UpperCase( str );
cout << str << endl;

4. 以下代碼有什么問(wèn)題?[C難]
void char2Hex( char c ) // 將字符以16進(jìn)制表示
{
char ch = c/0x10 + '0'; if( ch > '9' ) ch += ('A'-'9'-1);
char cl = c%0x10 + '0'; if( cl > '9' ) cl += ('A'-'9'-1);
cout << ch << cl << ' ';
}
char str[] = "I love 中國";
for( size_t i=0; i<strlen(str); ++i )
char2Hex( str[i] );
cout << endl;

5. 以下代碼有什么問(wèn)題?[C++易]
struct Test
{
Test( int ) {}
Test() {}
void fun() {}
};
void main( void )
{
Test a(1);
a.fun();
Test b();
b.fun();
}

6. 以下代碼有什么問(wèn)題?[C++易]
cout << (true?1:"1") << endl;

7. 以下代碼能夠編譯通過(guò)嗎,為什么?[C++易]
unsigned int const size1 = 2;
char str1[ size1 ];
unsigned int temp = 0;
cin >> temp;
unsigned int const size2 = temp;
char str2[ size2 ];

8. 以下代碼中的輸出語(yǔ)句輸出0嗎,為什么?[C++易]
struct CLS
{
int m_i;
CLS( int i ) : m_i(i) {}
CLS()
{
CLS(0);
}
};
CLS obj;
cout << obj.m_i << endl;

9. C++中的空類(lèi),默認產(chǎn)生哪些類(lèi)成員函數?[C++易]
答:
class Empty
{
public:
Empty(); // 缺省構造函數
Empty( const Empty& ); // 拷貝構造函數
~Empty(); // 析構函數
Empty& operator=( const Empty& ); // 賦值運算符
Empty* operator&(); // 取址運算符
const Empty* operator&() const; // 取址運算符 const
};

10. 以下兩條輸出語(yǔ)句分別輸出什么?[C++難]
float a = 1.0f;
cout << (int)a << endl;
cout << (int&)a << endl;
cout << boolalpha << ( (int)a == (int&)a ) << endl; // 輸出什么?
float b = 0.0f;
cout << (int)b << endl;
cout << (int&)b << endl;
cout << boolalpha << ( (int)b == (int&)b ) << endl; // 輸出什么?

11. 以下反向遍歷array數組的方法有什么錯誤?[STL易]
vector array;
array.push_back( 1 );
array.push_back( 2 );
array.push_back( 3 );
for( vector::size_type i=array.size()-1; i>=0; --i ) // 反向遍歷array數組
{
cout << array[i] << endl;
}

12. 以下代碼有什么問(wèn)題?[STL易]
typedef vector IntArray;
IntArray array;
array.push_back( 1 );
array.push_back( 2 );
array.push_back( 2 );
array.push_back( 3 );
// 刪除array數組中所有的2
for( IntArray::iterator itor=array.begin(); itor!=array.end(); ++itor )
{
if( 2 == *itor ) array.erase( itor );
}

13. 寫(xiě)一個(gè)函數,完成內存之間的拷貝。[考慮問(wèn)題是否全面]
答:
void* mymemcpy( void *dest, const void *src, size_t count )
{
char* pdest = static_cast<char*>( dest );
const char* psrc = static_cast<const char*>( src );
if( pdest>psrc && pdest<psrc+cout ) 能考慮到這種情況就行了
{
for( size_t i=count-1; i!=-1; --i )
pdest[i] = psrc[i];
}
else
{
for( size_t i=0; i<count; ++i )
pdest[i] = psrc[i];
}
return dest;
}
int main( void )
{
char str[] = "0123456789";
mymemcpy( str+1, str+0, 9 );
cout << str << endl;

system( "Pause" );
return 0;
}



本試題僅用于考查C++/C程序員的基本編程技能。內容限于C++/C常用語(yǔ)法,不涉及數據結構、算法以及深奧的語(yǔ)法??荚嚦煽?jì)能反映出考生的編程質(zhì)量以及對C++/C的理解程度,但不能反映考生的智力和軟件開(kāi)發(fā)能力。
筆試時(shí)間90分鐘。請考生認真答題,切勿輕視。


一、請填寫(xiě)BOOL , float, 指針變量 與“零值”比較的 if 語(yǔ)句。(10分)

提示:這里“零值”可以是0, 0.0 , FALSE或者“空指針”。例如 int 變量 n 與“零值”比較的 if 語(yǔ)句為:

if ( n == 0 )
if ( n != 0 )
以此類(lèi)推。

請寫(xiě)出 BOOL flag 與“零值”比較的 if 語(yǔ)句:
請寫(xiě)出 float x 與“零值”比較的 if 語(yǔ)句:
請寫(xiě)出 char *p 與“零值”比較的 if 語(yǔ)句:

二、以下為Windows NT下的32位C++程序,請計算sizeof的值(10分)
char str[] = “Hello” ;
char *p = str ;
int n = 10;
請計算
sizeof (str ) =
sizeof ( p ) =
sizeof ( n ) =
void Func ( char str[100])
{
請計算
sizeof( str ) =
}

void *p = malloc( 100 );
請計算
sizeof ( p ) =

三、簡(jiǎn)答題(25分)
1、頭文件中的 ifndef/define/endif 干什么用?
2、#include 和 #include “filename.h” 有什么區別?
3、const 有什么用途?(請至少說(shuō)明兩種)
4、在C++ 程序中調用被 C編譯器編譯后的函數,為什么要加 extern “C”聲明?
5、請簡(jiǎn)述以下兩個(gè)for循環(huán)的優(yōu)缺點(diǎn)
// 第一個(gè)
for (i=0; i++;)
{
if (condition)
DoSomething();
else
DoOtherthing();
}
// 第二個(gè)

if (condition)
{
for (i=0; i++;)
DoSomething();
}
else
{
for (i=0; i++;)
DoOtherthing();
}

優(yōu)點(diǎn):
缺點(diǎn):
優(yōu)點(diǎn):
缺點(diǎn):

四、有關(guān)內存的思考題(20分)
void GetMemory(char *p)
{
p = (char *)malloc(100);
}

void Test(void)
{
char *str = NULL;
GetMemory(str);
strcpy(str, "hello world");
printf(str);
}


請問(wèn)運行Test函數會(huì )有什么樣的結果?

答:
char *GetMemory(void)
{
char p[] = "hello world";
return p;
}

void Test(void)
{
char *str = NULL;
str = GetMemory();
printf(str);
}


請問(wèn)運行Test函數會(huì )有什么樣的結果?
答:
Void GetMemory2(char **p, int num)
{
*p = (char *)malloc(num);
}

void Test(void)
{
char *str = NULL;
GetMemory(&str, 100);
strcpy(str, "hello");
printf(str);
}

請問(wèn)運行Test函數會(huì )有什么樣的結果?

答:
void Test(void)
{
char *str = (char *) malloc(100);
strcpy(str, “hello”);
free(str);
if(str != NULL)
{
strcpy(str, “world”);
printf(str);
}
}

請問(wèn)運行Test函數會(huì )有什么樣的結果?

答:

五、編寫(xiě)strcpy函數(10分)
已知strcpy函數的原型是
char *strcpy(char *strDest, const char *strSrc);
其中strDest是目的字符串,strSrc是源字符串。
(1)不調用C++/C的字符串庫函數,請編寫(xiě)函數 strcpy
(2)strcpy能把strSrc的內容復制到strDest,為什么還要char * 類(lèi)型的返回值?

六、編寫(xiě)類(lèi)String的構造函數、析構函數和賦值函數(25分)
已知類(lèi)String的原型為:
class String
{
public:
String(const char *str = NULL); // 普通構造函數
String(const String &other); // 拷貝構造函數
~ String(void); // 析構函數
String & operate =(const String &other); // 賦值函數

private:
char *m_data; // 用于保存字符串
};

請編寫(xiě)String的上述4個(gè)函數。

附錄C :C++/C試題的答案與評分標準
一、請填寫(xiě)BOOL , float, 指針變量 與“零值”比較的 if 語(yǔ)句。(10分)

請寫(xiě)出 BOOL flag 與“零值”比較的 if 語(yǔ)句。(3分)

標準答案:
if ( flag )
if ( !flag )
如下寫(xiě)法均屬不良風(fēng)格,不得分。

if (flag == TRUE)
if (flag == 1 )
if (flag == FALSE)
if (flag == 0)

請寫(xiě)出 float x 與“零值”比較的 if 語(yǔ)句。(4分)

標準答案示例:

const float EPSINON = 0.00001;
if ((x >= - EPSINON) && (x <= EPSINON)
不可將浮點(diǎn)變量用“==”或“!=”與數字比較,應該設法轉化成“>=”或“<=”此類(lèi)形式。

如下是錯誤的寫(xiě)法,不得分。

if (x == 0.0)
if (x != 0.0)



請寫(xiě)出 char *p 與“零值”比較的 if 語(yǔ)句。(3分)

標準答案:

if (p == NULL)
if (p != NULL)
如下寫(xiě)法均屬不良風(fēng)格,不得分。

if (p == 0)
if (p != 0)

if (p)
if (!)

二、以下為Windows NT下的32位C++程序,請計算sizeof的值(10分)
char str[] = “Hello” ;
char *p = str ;
int n = 10;
請計算
sizeof (str ) = 6 (2分)
sizeof ( p ) = 4 (2分)
sizeof ( n ) = 4 (2分)
void Func ( char str[100])
{
請計算
sizeof( str ) = 4 (2分)
}

void *p = malloc( 100 );
請計算
sizeof ( p ) = 4 (2分)

三、簡(jiǎn)答題(25分)
1、頭文件中的 ifndef/define/endif 干什么用?(5分)
答:防止該頭文件被重復引用。

2、#include 和 #include “filename.h” 有什么區別?(5分)



華為的C\C++面試題

: Q1:請你分別劃劃OSI的七層網(wǎng)絡(luò )結構圖,和TCP/IP的五層結構圖?
: Q2:請你詳細的解釋一下IP協(xié)議的定義,在哪個(gè)層上面,主要有什么作用?
: TCP與UDP呢?
: 總得來(lái)說(shuō)前面兩道題目還是比較簡(jiǎn)單的!
: Q3:請問(wèn)交換機和路由器分別的實(shí)現原理是什么?分別在哪個(gè)層次上面實(shí)
: 現的?
: Q4:請問(wèn)C++的類(lèi)和C里面的struct有什么區別?
: Q5:請講一講析構函數和虛函數的用法和作用?
: Q6:全局變量和局部變量有什么區別?實(shí)怎么實(shí)現的?操作系統和編譯器
: 是怎么知道的?
: Q7:一些寄存器的題目,我忘記了具體實(shí)什么題目,主要好像是尋址和內
: 存管理等一些知識,不記得了。
: Q8:8086是多少尉的系統?在數據總線(xiàn)上是怎么實(shí)現的?還有一些硬件方
: 面的知識我既不清楚了。

: 一般建議參加華為的研發(fā)面試的同學(xué)先要準備一下相關(guān)的知識,軟件的主要
: 是看看C和數據結構方面的,硬件模電,數電和微機原理

兩道c面試題

1、一個(gè)學(xué)生的信息是:姓名,學(xué)號,性別,年齡等信息,用一個(gè)鏈表,把這些學(xué)生信息連在一起, 給出一個(gè)age, 在些鏈表中刪除學(xué)生年齡等于age的學(xué)生信息。

程序代碼
#i nclude "stdio.h"
#i nclude "conio.h"

struct stu{
char name[20];
char sex;
int no;
int age;
struct stu * next;
}*linklist;
struct stu *creatlist(int n)
{
int i;
//h為頭結點(diǎn),p為前一結點(diǎn),s為當前結點(diǎn)
struct stu *h,*p,*s;
h = (struct stu *)malloc(sizeof(struct stu));
h->next = NULL;
p=h;
for(i=0;i<n;i++)
{
s = (struct stu *)malloc(sizeof(struct stu));
p->next = s;
printf("Please input the information of the student: name sex no age \n");
scanf("%s %c %d %d",s->name,&s->sex,&s->no,&s->age);
s->next = NULL;
p = s;
}
printf("Create successful!");
return(h);
}
void deletelist(struct stu *s,int a)
{
struct stu *p;
while(s->age!=a)
{
p = s;
s = s->next;
}
if(s==NULL)
printf("The record is not exist.");
else
{
p->next = s->next;
printf("Delete successful!");
}
}
void display(struct stu *s)
{
s = s->next;
while(s!=NULL)
{
printf("%s %c %d %d\n",s->name,s->sex,s->no,s->age);
s = s->next;
}
}
int main()
{
struct stu *s;
int n,age;
printf("Please input the length of seqlist:\n");
scanf("%d",&n);
s = creatlist(n);
display(s);
printf("Please input the age:\n");
scanf("%d",&age);
deletelist(s,age);
display(s);
return 0;
}


2、實(shí)現一個(gè)函數,把一個(gè)字符串中的字符從小寫(xiě)轉為大寫(xiě)。

程序代碼
#i nclude "stdio.h"
#i nclude "conio.h"

void uppers(char *s,char *us)
{
for(;*s!='\0';s++,us++)
{
if(*s>='a'&&*s<='z')
*us = *s-32;
else
*us = *s;
}
*us = '\0';
}
int main()
{
char *s,*us;
char ss[20];
printf("Please input a string:\n");
scanf("%s",ss);
s = ss;
uppers(s,us);
printf("The result is:\n%s\n",us);
getch();
}


C/C++面試題大匯總之微軟亞洲技術(shù)中心面試題
1.進(jìn)程和線(xiàn)程的差別。
2.測試方法
3.Heap與stack的差別。
4.Windows下的內存是如何管理的?
5.介紹.Net和.Net的安全性。
6.客戶(hù)端如何訪(fǎng)問(wèn).Net組件實(shí)現Web Service?
7.C/C++編譯器中虛表是如何完成的?
8.談?wù)凜OM的線(xiàn)程模型。然后討論進(jìn)程內/外組件的差別。
9.談?wù)処A32下的分頁(yè)機制
10.給兩個(gè)變量,如何找出一個(gè)帶環(huán)單鏈表中是什么地方出現環(huán)的?
11.在IA32中一共有多少種辦法從用戶(hù)態(tài)跳到內核態(tài)?
12.如果只想讓程序有一個(gè)實(shí)例運行,不能運行兩個(gè)。像winamp一樣,只能開(kāi)一個(gè)窗口,怎樣實(shí)現?
13.如何截取鍵盤(pán)的響應,讓所有的‘a’變成‘b’?
14.Apartment在COM中有什么用?為什么要引入?
15.存儲過(guò)程是什么?有什么用?有什么優(yōu)點(diǎn)?
16.Template有什么特點(diǎn)?什么時(shí)候用?
17.談?wù)刉indows DNA結構的特點(diǎn)和優(yōu)點(diǎn)。
18.網(wǎng)絡(luò )編程中設計并發(fā)服務(wù)器,使用多進(jìn)程與多線(xiàn)程 ,請問(wèn)有什么區別?


軟件外企C++面試題 C\C++面試題集
1.What is achieved by prefixing the 'static' keyword to a file-level function or file-level variable declaration?

2.Describe the difference between the “IS A” and “HAS A” object relationships. Which is the stronger relationship and why?

3.Java & C# support interfaces directly with the “interface” keyword.
C++ does not have an “interface” keyword.
How do you create an interface in C++?
Where/when is the use of interfaces especially helpful?

4.If a program requires a large number of execution contexts what can be done to minimise thread scheduling overhead?
5. What does it mean to say that a function is reentrant?
What are some of the ways of achieving re-entrancy?

c語(yǔ)言面試題2道(華為) C++面試題更新
1、一個(gè)學(xué)生的信息是:姓名,學(xué)號,性別,年齡等信息,用一個(gè)鏈表,把這些學(xué)生信息連在一起, 給出一個(gè)age, 在些鏈表中刪除學(xué)生年齡等于age的學(xué)生信息。
#include "stdio.h"
#include "conio.h"
struct stu{
char name[20];
char sex;
int no;
int age;
struct stu * next;
}*linklist;
struct stu *creatlist(int n)
{
int i;
//h為頭結點(diǎn),p為前一結點(diǎn),s為當前結點(diǎn)
struct stu *h,*p,*s;
h = (struct stu *)malloc(sizeof(struct stu));
h->next = NULL;
p=h;
for(i=0;inext = s;
printf("Please input the information of the student: name sex no age \n");
scanf("%s %c %d %d",s->name,&s->sex,&s->no,&s->age);
s->next = NULL;
p = s;
}
printf("Create successful!");
return(h);
}
void deletelist(struct stu *s,int a)
{
struct stu *p;
while(s->age!=a)
{
p = s;
s = s->next;
}
if(s==NULL)
printf("The record is not exist.");
else
{
p->next = s->next;
printf("Delete successful!");
}
}
void display(struct stu *s)
{
s = s->next;
while(s!=NULL)
{
printf("%s %c %d %d\n",s->name,s->sex,s->no,s->age);
s = s->next;
}
}
int main()
{
struct stu *s;
int n,age;
printf("Please input the length of seqlist:\n");
scanf("%d",&n);
s = creatlist(n);
display(s);
printf("Please input the age:\n");
scanf("%d",&age);
deletelist(s,age);
display(s);
return 0;
}
2、實(shí)現一個(gè)函數,把一個(gè)字符串中的字符從小寫(xiě)轉為大寫(xiě)。
#include "stdio.h"
#include "conio.h"
void uppers(char *s,char *us)
{
for(;*s!='\0';s++,us++)
{
if(*s>='a'&&*s<='z')
*us = *s-32;
else
*us = *s;
}
*us = '\0';
}
int main()
{
char *s,*us;
char ss[20];
printf("Please input a string:\n");
scanf("%s",ss);
s = ss;
uppers(s,us);
printf("The result is:\n%s\n",us);
getch();
}

一道C語(yǔ)言的面試題

unsigned long val;
char a=0x96;
char b=0x81;

val= b<<8 | a;

問(wèn)val=___?


0x8196或0xffffff96。
取決于編譯器把char默認為無(wú)符號還是有符號。
字節作移位或算術(shù)一般定義為unsigned char

摩托羅拉部分C++面試題
我大體記得這些,有些問(wèn)題是我回答之后引出的,北京這邊各個(gè)部門(mén)不同會(huì )有差異,但大體這個(gè)意思
1.介紹一下STL,詳細說(shuō)明STL如何實(shí)現vector。
2.如果用VC開(kāi)發(fā)程序,常見(jiàn)這么幾個(gè)錯誤,C2001,c2005,c2011,這些錯誤的原因是什么。
3.繼承和委派有什么分別,在決定使用繼承或者委派的時(shí)候需要考慮什么。
4.指針和引用有什么分別;如果傳引用比傳指針安全,為什么?如果我使用常量指針難道不行嗎?
5.參數傳遞有幾種方式;實(shí)現多態(tài)參數傳遞采用什么方式,如果沒(méi)有使用某種方式原因是什么;
6.結合一個(gè)項目說(shuō)明你怎樣應用設計模式的理念。
7.介紹一下你對設計模式的理解。(這個(gè)過(guò)程中有很多很細節的問(wèn)題隨機問(wèn)的)
8.C++和C定義結構的分別是什么。
9.構造函數可否是虛汗數,為什么?析構函數呢,可否是純虛的呢?
10,拷貝構造函數相關(guān)問(wèn)題,深拷貝,淺拷貝,臨時(shí)對象等。
11.結合1個(gè)你認為比較能體現OOP思想的項目,用UML來(lái)描述。(最好這個(gè)項目繼承,多態(tài),虛函數都有體現)這個(gè)問(wèn)題大概會(huì )占面試時(shí)間的一半,并且會(huì )問(wèn)很多問(wèn)題,一不小心可能會(huì )被問(wèn)?。?。
12?;?lèi)的有1個(gè)虛函數,子類(lèi)還需要申明為virtual嗎?為什么。
13.C也可以通過(guò)精心封裝某些函數功能實(shí)現重用,那C++的類(lèi)有什么優(yōu)點(diǎn)嗎,難道僅僅是為實(shí)現重用。
14.C++特點(diǎn)是什么,如何實(shí)現多態(tài)?畫(huà)出基類(lèi)和子類(lèi)在內存中的相互關(guān)系。
15.為什么要引入抽象基類(lèi)和純虛函數?
16.介紹一下模板和包容器。如何實(shí)現?(也許會(huì )讓你當場(chǎng)舉例實(shí)現)
17.你如何理解MVC。簡(jiǎn)單舉例來(lái)說(shuō)明其應用。
18,多重繼承如何消除向上繼承的二義性。
本站僅提供存儲服務(wù),所有內容均由用戶(hù)發(fā)布,如發(fā)現有害或侵權內容,請點(diǎn)擊舉報。
打開(kāi)APP,閱讀全文并永久保存 查看更多類(lèi)似文章
猜你喜歡
類(lèi)似文章
C語(yǔ)言面試題
285-304
memset
第三章 class
C++對C語(yǔ)言的非面向對象特性擴充(1)
C++基礎技巧筆記
更多類(lèi)似文章 >>
生活服務(wù)
分享 收藏 導長(cháng)圖 關(guān)注 下載文章
綁定賬號成功
后續可登錄賬號暢享VIP特權!
如果VIP功能使用有故障,
可點(diǎn)擊這里聯(lián)系客服!

聯(lián)系客服

欧美性猛交XXXX免费看蜜桃,成人网18免费韩国,亚洲国产成人精品区综合,欧美日韩一区二区三区高清不卡,亚洲综合一区二区精品久久