返回列表 發帖
  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.     static List<int> scores = new List<int> { 100, 100, 95, 95, 92, 91, 90, 100, 88, 88, 87, 87, 90, 91, 85, 80, 81, 82, 82, 89 };

  9.     static void Main()
  10.     {
  11.         try
  12.         {
  13.             int socre=Convert.ToInt32(Console.ReadLine());
  14.             //查找列表中與score相同的成績必製作一張列表出來
  15.             List<int> finds = scores.FindAll(delegate (int s)
  16.             {
  17.                 return s.Equals(socre);
  18.             });
  19.             Console.WriteLine(finds.Count.ToString());
  20.         }catch
  21.         {
  22.             Console.WriteLine("error");
  23.         }
  24.         Console.ReadKey();

  25.    

  26.     }

  27. }
複製代碼
istak.teach2@gmail.com

TOP

  1. using ConsoleApp1;
  2. using System;//程式庫呼叫
  3. using System.ComponentModel.DataAnnotations;
  4. using System.Linq.Expressions;
  5. using ABC.qq;
  6. using System.Globalization;

  7. namespace A
  8. {
  9.     class Program//負責一部分工作的人
  10.     {
  11.         static List<int> scores = new List<int> { 100, 100, 95, 95, 92, 91, 90, 100, 88, 88, 87, 87, 90, 91, 85, 80, 81, 82, 82, 89 };

  12.         static void Main()
  13.         {
  14.             try
  15.             {
  16.                 int score = Convert.ToInt32(Console.ReadLine());
  17.                 int count = 0;
  18.                 foreach (int i in scores)
  19.                 {
  20.                     if (i == score)
  21.                         count++;
  22.                 }
  23.                 Console.WriteLine(count);
  24.             }
  25.             catch
  26.             {
  27.                 Console.WriteLine("error");
  28.             }
  29.             Console.ReadKey();

  30.         }
  31.     }
  32. }
複製代碼
istak.teach2@gmail.com

TOP

返回列表