- using ConsoleApp1;
- using System;//程式庫呼叫
- using System.ComponentModel.DataAnnotations;
- using System.Linq.Expressions;
- using ABC.qq;
- class Program//負責一部分工作的人
- {
- const string dreams = "There are moments in life when you miss someone so much that " +
- "you just want to pick them from your dreams and hug them for real! Dream what " +
- "you want to dream;go where you want to go;be what you want to be,because you have " +
- "only one life and one chance to do all the things you want to do";
- static void Main()//method ..Entry Point 程式進入點
- {
- try
- {
- string x1 = Console.ReadLine();
- int times = 0;
- int pos = dreams.IndexOf(x1);
- while (pos > -1)
- {
- times++;
- pos = dreams.IndexOf(x1,pos+1);//往下一個搜尋
- }
- Console.WriteLine(times);
- }catch
- {
- Console.WriteLine("error");
- }
-
-
- }
- }
- /*
- * ArgumentException是一個自訂「合法參數」的例外,
- * ArgumentException類別所接受的合法參數,是由程式設計師自行設定的。
- *
- * FormatException當參數格式不符合呼叫的方法的參數規範時引發的異常.
- */
複製代碼 |