freepeople性欧美熟妇, 色戒完整版无删减158分钟hd, 无码精品国产vα在线观看DVD, 丰满少妇伦精品无码专区在线观看,艾栗栗与纹身男宾馆3p50分钟,国产AV片在线观看,黑人与美女高潮,18岁女RAPPERDISSSUBS,国产手机在机看影片

正文內(nèi)容

程序員筆試面試-資料下載頁(yè)

2025-07-30 02:49本頁(yè)面
  

【正文】 位為一個(gè)數(shù),寫(xiě)函數(shù)求他們的和。解釋:整數(shù)1101010110110111和 1101+0101+1011+0111感覺(jué)應(yīng)該不難,當(dāng)時(shí)對(duì)題理解的不是很清楚,所以寫(xiě)了一個(gè)函數(shù),也不知道對(duì)不對(duì)。疑問(wèn): 既然是16位的整數(shù),1101010110110111是2進(jìn)制的,那么函數(shù)參數(shù)怎么定義呢,請(qǐng)大蝦指教。答案:用十進(jìn)制做參數(shù),計(jì)算時(shí)按二進(jìn)制考慮。/* n就是16位的數(shù),函數(shù)返回它的四個(gè)部分之和 */char SumOfQuaters(unsigned short n){ char c = 0。 int i = 4。 do { c += n amp。 15。 n = n 4。 } while (i)。 return c。}有1,2,....一直到n的無(wú)序數(shù)組,求排序算法,并且要求時(shí)間復(fù)雜度為O(n),空間復(fù)雜度O(1),使用交換,而且一次只能交換兩個(gè)數(shù).(華為)includeint main(){ int a[] = {10,6,9,5,2,8,4,7,1,3}。 int len = sizeof(a) / sizeof(int)。 int temp。 for(int i = 0。 i len。 ) {temp = a[a[i] 1]。a[a[i] 1] = a[i]。a[i] = temp。if ( a[i] == i + 1) i++。 } for (int j = 0。 j len。 j++) couta[j],。 return 0。}(慧通)1 寫(xiě)出程序把一個(gè)鏈表中的接點(diǎn)順序倒排typedef struct linknode{int data。struct linknode *next。}node。//將一個(gè)鏈表逆置node *reverse(node *head){node *p,*q,*r。p=head。q=pnext。while(q!=NULL){r=qnext。qnext=p。p=q。q=r。}headnext=NULL。head=p。return head。}2 寫(xiě)出程序刪除鏈表中的所有接點(diǎn)void del_all(node *head){node *p。while(head!=NULL){p=headnext。free(head)。head=p。}cout 釋放空間成功!endl。}3兩個(gè)字符串,s,t。把t字符串插入到s字符串中,s字符串有足夠的空間存放t字符串void insert(char *s, char *t, int i){char *q = t。char *p =s。if(q == NULL)return。while(*p!=39。\039。){p++。}while(*q!=0){*p=*q。p++。q++。}*p = 39。\039。}分析下面的代碼:char *a = hello。char *b = hello。if(a= =b)printf(YES)。elseprintf(NO)。這個(gè)簡(jiǎn)單的面試題目,我選輸出 no(對(duì)比的應(yīng)該是指針地址吧),可在VC是YES 在C是NOlz的呢,是一個(gè)常量字符串。位于靜態(tài)存儲(chǔ)區(qū),它在程序生命期內(nèi)恒定不變。如果編譯器優(yōu)化的話,會(huì)有可能a和b同時(shí)指向同一個(gè)hello的。則地址相同。如果編譯器沒(méi)有優(yōu)化,那么就是兩個(gè)不同的地址,則不同謝謝!寫(xiě)一個(gè)函數(shù),功能:完成內(nèi)存之間的拷貝memcpy source code: 270 void* memcpy( void *dst, const void *src, unsigned int len ) 271 { 272 register char *d。 273 register char *s。 27 275 if (len == 0) 276 return dst。 277 278 if (is_overlap(dst, src, len, len)) 279 plain3(memcpy, dst, src, len)。 280 281 if ( dst src ) { 282 d = (char *)dst + len 1。 283 s = (char *)src + len 1。 284 while ( len = 4 ) { 285 *d = *s。 286 *d = *s。 287 *d = *s。 288 *d = *s。 289 len = 4。 290 } 291 while ( len ) { 292 *d = *s。 293 } 294 } else if ( dst src ) { 295 d = (char *)dst。 296 s = (char *)src。 297 while ( len = 4 ) { 298 *d++ = *s++。 299 *d++ = *s++。 300 *d++ = *s++。 301 *d++ = *s++。 302 len = 4。 303 } 304 while ( len ) { 305 *d++ = *s++。 306 } 307 } 308 return dst。 309 }公司考試這種題目主要考你編寫(xiě)的代碼是否考慮到各種情況,是否安全(不會(huì)溢出)各種情況包括:1、參數(shù)是指針,檢查指針是否有效2、檢查復(fù)制的源目標(biāo)和目的地是否為同一個(gè),若為同一個(gè),則直接跳出3、讀寫(xiě)權(quán)限檢查4、安全檢查,是否會(huì)溢出memcpy拷貝一塊內(nèi)存,內(nèi)存的大小你告訴它strcpy是字符串拷貝,遇到39。\039。結(jié)束/* memcpy ─── 拷貝不重疊的內(nèi)存塊 */ void memcpy(void* pvTo, void* pvFrom, size_t size){void* pbTo = (byte*)pvTo。void* pbFrom = (byte*)pvFrom。ASSERT(pvTo != NULL amp。amp。 pvFrom != NULL)。 //檢查輸入指針的有效性ASSERT(pbTo=pbFrom+size || pbFrom=pbTo+size)。//檢查兩個(gè)指針指向的內(nèi)存是否重疊while(size0)*pbTo++ == *pbFrom++。return(pvTo)。}華為面試題:怎么判斷鏈表中是否有環(huán)?bool CircleInList(Link* pHead){if(pHead = = NULL || pHeadnext = = NULL)//無(wú)節(jié)點(diǎn)或只有一個(gè)節(jié)點(diǎn)并且無(wú)自環(huán)return (false)。if(pHeadnext = = pHead)//自環(huán)return (true)。Link *pTemp1 = pHead。//step 1Link *pTemp = pHeadnext。//step 2while(pTemp != pTemp1 amp。amp。 pTemp != NULL amp。amp。 pTempnext != NULL){pTemp1 = pTemp1next。pTemp = pTempnextnext。}if(pTemp = = pTemp1)return (true)。return (false)。}兩個(gè)字符串,s,t。把t字符串插入到s字符串中,s字符串有足夠的空間存放t字符串void insert(char *s, char *t, int i){memcpy(amp。s[strlen(t)+i],amp。s[i],strlen(s)i)。memcpy(amp。s[i],t,strlen(t))。s[strlen(s)+strlen(t)]=39。\039。}1。編寫(xiě)一個(gè) C 函數(shù),該函數(shù)在一個(gè)字符串中找到可能的最長(zhǎng)的子字符串,且該字符串是由同一字符組成的。char * search(char *cpSource, char ch){ char *cpTemp=NULL, *cpDest=NULL。 int iTemp, iCount=0。 while(*cpSource) { if(*cpSource == ch) { iTemp = 0。 cpTemp = cpSource。 while(*cpSource == ch) ++iTemp, ++cpSource。 if(iTemp iCount) iCount = iTemp, cpDest = cpTemp。 if(!*cpSource) break。 } ++cpSource。 } return cpDest。} 2。請(qǐng)編寫(xiě)一個(gè) C 函數(shù),該函數(shù)在給定的內(nèi)存區(qū)域搜索給定的字符,并返回該字符所在位置索引值。int search(char *cpSource, int n, char ch){ int i。 for(i=0。 in amp。amp。 *(cpSource+i) != ch。 ++i)。 return i。}一個(gè)單向鏈表,不知道頭節(jié)點(diǎn),一個(gè)指針指向其中的一個(gè)節(jié)點(diǎn),問(wèn)如何刪除這個(gè)指針指向的節(jié)點(diǎn)?將這個(gè)指針指向的next節(jié)點(diǎn)值copy到本節(jié)點(diǎn),將next指向nextnext,并隨后刪除原next指向的節(jié)點(diǎn)。include void foo(int m, int n){ printf(m=%d, n=%d\n, m, n)。}int main(){ int b = 3。 foo(b+=3, ++b)。 printf(b=%d\n, b)。return 0。}輸出:m=7,n=4,b=7()這種方式和編譯器中得函數(shù)調(diào)用關(guān)系相關(guān)即先后入棧順序。不過(guò)不同編譯器得處理不同。也是因?yàn)镃標(biāo)準(zhǔn)中對(duì)這種方式說(shuō)明為未定義,所以各個(gè)編譯器廠商都有自己得理解,所以最后產(chǎn)生得結(jié)果完全不同。因?yàn)檫@樣,所以遇見(jiàn)這種函數(shù),我們首先要考慮我們得編譯器會(huì)如何處理這樣得函數(shù),其次看函數(shù)得調(diào)用方式,不同得調(diào)用方式,可能產(chǎn)生不同得結(jié)果。最后是看編譯器優(yōu)化。,實(shí)現(xiàn)刪除字符串str1中含有的字符串str2.第二個(gè)就是利用一個(gè)KMP匹配算法找到str2然后刪除(用鏈表實(shí)現(xiàn)的話,便捷于數(shù)組)/*雅虎筆試題(字符串操作) 給定字符串A和B,輸出A和B中的最大公共子串。比如A=aocdfe B=pmcdfa 則輸出cdf*///Author: azhenincludeincludeincludechar *manstring(char shortstring[], char longstring[]){int i, j。char *substring=malloc(256)。if(strstr(longstring, shortstring)!=NULL) //如果……,那么返回shortstringreturn shortstring。 for(i=strlen(shortstring)1。i0。 i) //否則,開(kāi)始循環(huán)計(jì)算{for(j=0。 j=strlen(shortstring)i。 j++){memcpy(substring, amp。shortstring[j], i)。substring[i]=39。\039。if(strstr(longstring, substring)!=NULL)return substring。}}return NULL。}main()
點(diǎn)擊復(fù)制文檔內(nèi)容
環(huán)評(píng)公示相關(guān)推薦
文庫(kù)吧 www.dybbs8.com
備案圖鄂ICP備17016276號(hào)-1