線上訂房服務-台灣趴趴狗聯合訂房中心
發文 回覆 瀏覽次數:1188
推到 Plurk!
推到 Facebook!

C++ problem about loop <URGENT>

 
99168
一般會員


發表:1
回覆:0
積分:0
註冊:2006-10-22

發送簡訊給我
#1 引用回覆 回覆 發表時間:2006-10-21 00:17:42 IP:218.255.xxx.xxx 未訂閱
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

發送簡訊給我
#2 引用回覆 回覆 發表時間:2006-11-03 15:19:51 IP:140.130.xxx.xxx 訂閱
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
系統時間:2024-05-10 13:41:31
聯絡我們 | Delphi K.Top討論版
本站聲明
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。
2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。
3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇!