C++ problem about loop <URGENT> |
|
99168
一般會員 發表:1 回覆:0 積分:0 註冊:2006-10-22 發送簡訊給我 |
I have some problems with this question. I spend a whole day to solve still cant get it>.<
This question is about loop. Question: A string "s" is repeating if it can be written as s1s2...sn, where s1 = s2 =...=sn and n >= 2. Write a program that takes a string and prints the longest substring (largest in length) that is repeating. If there is more than one such substring, your program should print the one that is closest to the left. On the other hand, if there is no repeating substring, your program should print "no repeating substring". Here are some sample runs. 1) C:\MyProg> lrs input : abcddddabc output : dddd 2) C:\MyProg> lrs abababcabcpqpqr ababab 3) C:\MyProg>lrs ababpqrpqrabcabc pqrpqr 4) C:\MyProg>lrs abcdabc no repeating substring |
remmurds
一般會員 發表:17 回覆:14 積分:16 註冊:2006-10-29 發送簡訊給我 |
I wrote a program some years ago.
I think this program is similar than your case. http://stud.sju.edu.tw/~89104011/unit.cpp
------
隨筆網誌: http://reassert.blogspot.com |
本站聲明 |
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。 2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。 3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇! |