반응형
소수점 자릿수 알아보기
using System;
using System.Collections.Generic;
using System.Text;
namespace baek2
{
class Program
{
static void Main(string[] args)
{
double total = 0;
double score_total = 0;
for (int i = 0; i<20 ;i++)
{
string subject = Console.ReadLine();
string[] token = subject.Split();
string name = token[0];
double credit = double.Parse(token[1]);
string score = token[2];
if(score == "A+")
{
total += credit;
score_total += (4.5 * credit);
}
else if(score == "A0")
{
total += credit;
score_total += (4.0 * credit);
}
else if (score == "B+")
{
total += credit;
score_total += (3.5 * credit);
}
else if (score == "B0")
{
total += credit;
score_total += (3.0 * credit);
}
else if (score == "C+")
{
total += credit;
score_total += (2.5 * credit);
}
else if (score == "C0")
{
total += credit;
score_total += (2.0 * credit);
}
else if (score == "D+")
{
total += credit;
score_total += (1.5 * credit);
}
else if (score == "D0")
{
total += credit;
score_total += (1.0 * credit);
}
else if (score == "F")
{
total += credit;
score_total += (0.0 * credit);
}
}
Console.WriteLine(Math.Round(score_total/total,6));
}
}
}
반응형
'코딩테스트 준비 > 백준 C#' 카테고리의 다른 글
백준 C# - 2566 (0) | 2023.05.17 |
---|---|
백준 C# - 2738 (0) | 2023.05.15 |
백준 C# - 1316 (0) | 2023.05.15 |
백준 C# - 2941 (0) | 2023.05.15 |
백준 C# - 4344 (0) | 2023.05.13 |
댓글