H面試程式(6) 字串中找出連續最長的數字串

2021-06-18 08:51:24 字數 765 閱讀 4655

//1. 寫乙個函式,它的原形是int continumax(char *outputstr,char *intputstr)

//功能:

//在字串中找出連續最長的數字串,並把這個串的長度返回,

//並把這個最長數字串付給其中乙個函式引數outputstr所指記憶體。

#include#includeint continumax(char *outputstr,char *inputstr)

if(length > maxlength)

length = 0;

continue;

} i++;

length = 0;

} outputstr[j] = '\0';

return maxlength;

}int main( )

ii

#include#includeint continumax(char * outputstr, char * inputstr)

else if (len > max) //如果統計出來的數字字串大於當前的最大數字子字串的長度,則更新

inputstr++;

} for(int i = 0 ; ioutputstr = outputstr-max;

outputstr[max] ='\0';

cout

int main()

H面試程式(27) 字串轉換

1 字串轉換 問題描述 將輸入的字串 字串僅包含小寫字母 a 到 z 按照如下規則,迴圈轉換後輸出 a b,b c,y z,z a 若輸入的字串連續出現兩個字母相同時,後乙個字母需要連續轉換2次。例如 aa 轉換為 bc,zz 轉換為 ab 當連續相同字母超過兩個時,第三個出現的字母按第一次出現算。...

6 字串函式

strcpy函式char strcpy char dest,const char src 功能 把src所指向的字串覆蓋複製到dest。返回值 dest指向的字串。注意 字串src的長度不能超過dest,否則會溢位。strncpy函式char strncpy char dest,const char...

6 字串拼接

字串相加 alert hello world hello world 數值字串相加 alert 100 100 100100 數值字串 數值 alert 11 12 1112口訣 數值相加,字元相連 var age 18 console.log pink老師age歲啦 這樣不行 console.lo...