Presentation is loading. Please wait.

Presentation is loading. Please wait.

10393:The One-Handed Typist

Similar presentations


Presentation on theme: "10393:The One-Handed Typist"— Presentation transcript:

1 10393:The One-Handed Typist
★☆☆☆☆ 題組:Problem Set Archive with Online Judge 題號:10393:The One-Handed Typist 解題者:張育誠 解題日期:2018年3月4日 題意:Jimmy因受傷導致某些手指頭無法使用,而導致鍵 盤上一些英文無法順暢輸入。input會給哪幾隻手指頭受傷與需輸入的字串。找出能輸入且最長的字串們。   最後輸出共有幾個最長單字與依序排列好的單字們。

2 題意範例: Input: 5 5 the stewardesses have funny hair Output: 1 手指頭可輸入的按鍵 ↑

3 解法:用暴力法 解法範例: 3 5 7 8 9 waxed waxer waxers waxing wearable -> hurt : “yhnujmik,ol.” -> 使用find_first_of() 或 find_last_of() -> 存入set -> 使用iterator來印出結果 -> 輸出: waxers string a = World-45--” string b = “ABC….Zabc….z” int first = b.find_first_of(a) int last = b.find_last_of(a) 如果找不到,回傳string::npos

4 討論: (1) 為什麼不能使用find(),而要使用find_first_of()或 find_last_of()? (2) 如果尋找的不是”單字“,而是含space的字串, 該作法會不會無效?


Download ppt "10393:The One-Handed Typist"

Similar presentations


Ads by Google