#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;
}
#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,多重繼承如何消除向上繼承的二義性。