- using ConsoleApp1;
- using System;//程式庫呼叫
- using System.ComponentModel.DataAnnotations;
- using System.Linq.Expressions;
- using ABC.qq;
- class Program//負責一部分工作的人
- {
- static void Main()//method ..Entry Point 程式進入點
- {
- int[] numbers = new int[5];
- float number;
- for(int i=0;i<numbers.Length; i++)
- {
- float.TryParse(Console.ReadLine(), out number);
- numbers[i] = (int)number;
- }
- compute(numbers);
- }
- static void compute(int[] numbers)
- {
- int sum = 0, times = 0;
- for(int i=0;i< numbers.Length;i++)
- {
- if (numbers[i] >50)
- {
- sum += numbers[i];
- times++;
- }
- }
- Console.WriteLine(sum);
- if(times > 0 )
- {
- Console.WriteLine(sum / times);
- }else
- {
- Console.WriteLine("0");
- }
- }
- }
複製代碼 |