Bài 2. Xâu chung(Không dùng thủ tục và hàm) Xâu S được gọi là xâu con chung của xâu S1 và xâu S2 nếu xâu S là một dãy các ký tự liên tiếp trong S1 và cũng là dãy các ký tự liên tiếp trong S2. Yêu cầu: Cho hai xâu kí tự S1 và S2 (có không quá 255 ký tự). Hãy tìm một xâu con chung S dài nhất của hai xâu S1 và S2. Ví dụ: S1 = ’Ky thi học sinh gioi Tinh môn Tin hoc’, S2 = ’hoc sinh gioi mon Tin hoc’ thì S = ‘hoc sinh gioi '. Dữ liệu vào từ file văn bản Bai2.inp: • Dòng đầu tiên ghi xâu S1; • Dòng thứ hai ghi xâu S2. Kết quả ghi ra file văn bản Bai4.out: Chỉ một số duy nhất là độ dài của xâu con chung dài nhất S. (Nếu hai xâu S1, S2 không có kí tự nào chung thì ghi số 0). Bai2.inp Ky thi hoc sinh gioi Tinh mon tin hoc hoc sinh gioi mon Tin hoc Bai2.out 14

Các câu hỏi liên quan

Exercise 5 : Rewrite the sentences without changing the meaning 1. Huyen My sings beautifully. Her sister sings more beautifully than her. (AS ... AS) ............................................................................................................. 2. The new sculpture is 4 metres high. The old sculpture is 4.2 metres high. (AS ... AS) .................................................................................................................................... 3. I usually stayed up late to watch football matches last year, but now I don’t. → I used...................................................................................................................... 4. There were some trees in the field, but now there aren’t any. → There used .............................................................................................................. 5. They have very little money. They are happy. (in spite of) .................................................................................................................................... 6. My foot was injured. I managed to walk to the nearest village. (although) .................................................................................................................................... 7. Do you enjoy listening to music? -> Are …………………….…………………………… 8. The blue dress is cheaper than the red one.  The red dress isn’t ……………………………………… 9. Mr. Hai usually has stomach problems. He eats dinner very close to the bedtime. (so) ……………………………………………………………………………………… 10. My dad has a lot of carved eggs. He has never sold any of them. (but) ……………………………………………………………………………………………… 11. I am interested in watching TV in the evening .-> I enjoy… …………………………………………………………………………………. 12. Titanic is a really good movie. It is not for anyone under the age of sixteen. (However) ………………………………………………………………………………………