程式設計題 將乙個字串中連續最長的數字串列印出來

2021-08-28 18:57:28 字數 750 閱讀 7301

題目要求:寫乙個函式,原型為int continumax(char *outputstr,char *inputstr),功能:在字串中 找出連續最長的數字串,並把這個串的長度返回,同時把這個最長的數字串付給其中乙個引數outputstr所指記憶體,例如:"abcd12345ed125ss123456789aa"的首位址傳給inputstr後,函式返回9,outputstr所指的值為123456789.

#include #include #include using namespace std;

int continumax(char *outputstr,char *inputstr)

; //臨時陣列存放數字串

int count = 0;

int num = 0;

for(int i = 0;i < len;i++) //遍歷輸入字串

}} else

}

count = 0; //count清零重新記錄下個數字段長度

} }inputstr = &temp[0];

cout << inputstr << endl;

return num;

}int main()

; int num = 0;

num = continumax(str,str1);

printf("%d\n",num);

return 0;

}

將乙個字串逆序

這個題要我自己寫還不太有思路,可能不會想到寫三個函式,而且這個 也沒有執行出來 include include include pragma warning disable 4996 有乙個字元陣列的內容為 student a am i 請你將陣列的內容改為 i am a student 要求 不能...

在乙個字串中尋找另外乙個字串

在乙個字串中尋找另外乙個字串 public class text foundit true break test system.out.println foundit?found it didn t find it 該段程式有點難以理解,主要就是if語句的理解,if searchme.charat ...

找出乙個字串中最長的連續回文

找出乙個字串中最長的連續回文 題目 找出乙個字串中最長的回文,比如goooogleel,最長回文是goooog 分析 第一,定義乙個pstr指向字串str,再定義乙個p指向pstr,q指向pstr 1 第二,找出乙個字元 p與其下乙個字元 q相同位置,比如oo,num index p 然後比較這兩個...