亚洲喷奶水中文字幕电影,日本aⅴ高清一区二区三区,欧美亚洲日本国产,欧美日韩亚洲中文字幕

<legend id="flx4p"><abbr id="flx4p"><thead id="flx4p"></thead></abbr></legend>

<mark id="flx4p"><thead id="flx4p"></thead></mark>

      C語言面試題

        1、編寫一個 C 函數(shù),該函數(shù)在一個字符串中找到可能的最長的子字符串,且該字符串是由同一字符組成的。

        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、請編寫一個 C 函數(shù),該函數(shù)在給定的內(nèi)存區(qū)域搜索給定的字符,并返回該字符所在位置索引值。

        int search(char *cpSource, int n, char ch)

        {

        int i;

        for(i=0; i return i;

        }

        一個單向鏈表,不知道頭節(jié)點(diǎn),一個指針指向其中的一個節(jié)點(diǎn),問如何刪除這個指針指向的節(jié)點(diǎn)?

        將這個指針指向的next節(jié)點(diǎn)值copy到本節(jié)點(diǎn),將next指向next->next,并隨后刪除原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(VC6.0)

        這種方式和編譯器中得函數(shù)調(diào)用關(guān)系相關(guān)即先后入棧順序。不過不同

        編譯器得處理不同。也是因為C標(biāo)準(zhǔn)中對這種方式說明為未定義,所以

        各個編譯器廠商都有自己得理解,所以最后產(chǎn)生得結(jié)果完全不同。

        因為這樣,所以遇見這種函數(shù),我們首先要考慮我們得編譯器會如何處理

        這樣得函數(shù),其次看函數(shù)得調(diào)用方式,不同得調(diào)用方式,可能產(chǎn)生不同得

        結(jié)果。最后是看編譯器優(yōu)化。

        2.寫一函數(shù),實現(xiàn)刪除字符串str1中含有的字符串str2.

        第二個就是利用一個KMP匹配算法找到str2然后刪除(用鏈表實現(xiàn)的話,便捷于數(shù)組)

        /*雅虎筆試題(字符串操作)

        給定字符串A和B,輸出A和B中的最大公共子串。

        比如A=”aocdfe” B=”pmcdfa” 則輸出”cdf”

        */

        //Author: azhen

        #include

        #include

        #include

        char *commanstring(char shortstring[], char longstring[])

        {

        int i, j;

        char *substring=malloc(256);

        if(strstr(longstring, shortstring)!=NULL) //如果……,那么返回shortstring

        return shortstring;

        for(i=strlen(shortstring)-1;i>0; i–) //否則,開始循環(huán)計算

        {

        for(j=0; j<=strlen(shortstring)-i; j++){

        memcpy(substring, &shortstring[j], i);

        substring[i]='\0';

        if(strstr(longstring, substring)!=NULL)

        return substring;

        }

        }

        return NULL;

        }

        main()

        {

        char *str1=malloc(256);

        char *str2=malloc(256);

        char *comman=NULL;

        gets(str1);

        gets(str2);

        if(strlen(str1)>strlen(str2)) //將短的字符串放前面

        comman=commanstring(str2, str1);

        else

        comman=commanstring(str1, str2);

        printf(“the longest comman string is: %s\n”, comman);

        }

        11.寫一個函數(shù)比較兩個字符串str1和str2的大小,若相等返回0,若str1大于

        str2返回1,若str1小于str2返回-1

        int strcmp ( const char * src,const char * dst)

        {

        int ret = 0 ;

        while( ! (ret = *(unsigned char *)src – *(unsigned char *)dst) && *dst)

        {

        ++src;

        ++dst;

        }

        if ( ret < 0 )

        ret = -1 ;

        else if ( ret > 0 )

        ret = 1 ;

        return( ret );

        }

        3,求1000!的未尾有幾個0(用素數(shù)相乘的方法來做,如72=2*2*2*3*3);

        求出1->1000里,能被5整除的數(shù)的個數(shù)n1,能被25整除的數(shù)的個數(shù)n2,能被125整除的數(shù)的個數(shù)n3,

        能被625整除的數(shù)的個數(shù)n4.

        1000!末尾的零的個數(shù)=n1+n2+n3+n4;

        #include

        #define NUM 1000

        int find5(int num){

        int ret=0;

        while(num%5==0){

        num/=5;

        ret++;

        }

        return ret;

        }

        int main(){

        int result=0;

        int i;

        for(i=5;i<=NUM;i+=5)

        {

        result+=find5(i);

        }

        printf(” the total zero number is %d\n”,result);

        return 0;

        }

      本文已影響6827
      上一篇:C/C++有關(guān)內(nèi)存的面試思考題 下一篇:外企C語言面試筆試題

      相關(guān)文章推薦

      |||||