C#

01.C# - 알고리즘 : 합계

Godffs 2009. 8. 5. 20:20
반응형
합계 알고리즘 예제 입니다.

using System;

public class 합계
{
    public static void Main(string[] args)
    {
        //[1] Input : 5명의 국어 점수
        int[] score = { 75, 50, 37, 90, 95 };
       int sum = 0;

        //[2] Process : SUM
        foreach (int item in score)
        {
            if (item >= 80)
            {
                sum += item;
            }
        }

        //[3] Output
        Console.WriteLine("5명의 점수중 80점 이상의 총점: {0} 이고
                                  인원은 {1}명", sum, score.Length);

    }
}

반응형