返回列表 發帖
  1. using ConsoleApp1;
  2. using System;//程式庫呼叫
  3. using System.ComponentModel.DataAnnotations;
  4. using System.Linq.Expressions;
  5. using ABC.qq;


  6. class Program//負責一部分工作的人
  7. {
  8.     const string dreams = "There are moments in life when you miss someone so much that " +
  9.     "you just want to pick them from your dreams and hug them for real! Dream what " +
  10.     "you want to dream;go where you want to go;be what you want to be,because you have " +
  11.     "only one life and one chance to do all the things you want to do";
  12.     static void Main()//method ..Entry Point 程式進入點
  13.     {
  14.        try
  15.         {
  16.             string x1 = Console.ReadLine();
  17.             int times = 0;
  18.             int pos = dreams.IndexOf(x1);
  19.             while (pos > -1)
  20.             {
  21.                 times++;
  22.                 pos = dreams.IndexOf(x1,pos+1);//往下一個搜尋

  23.             }
  24.             Console.WriteLine(times);
  25.         }catch
  26.         {
  27.             Console.WriteLine("error");
  28.         }

  29.       
  30.         

  31.     }

  32. }
  33.     /*
  34.      * ArgumentException是一個自訂「合法參數」的例外,
  35.      * ArgumentException類別所接受的合法參數,是由程式設計師自行設定的。
  36.      *
  37.      * FormatException當參數格式不符合呼叫的方法的參數規範時引發的異常.
  38.      */
複製代碼
istak.teach2@gmail.com

TOP

返回列表