https://www.acmicpc.net/problem/1546
2741๋ฒ: N ์ฐ๊ธฐ
์์ฐ์ N์ด ์ฃผ์ด์ก์ ๋, 1๋ถํฐ N๊น์ง ํ ์ค์ ํ๋์ฉ ์ถ๋ ฅํ๋ ํ๋ก๊ทธ๋จ์ ์์ฑํ์์ค.
www.acmicpc.net
My Solution
float int ํต์ผํด์ผ์ง ใ ใ
using System;
namespace ConsoleApp1
{
class Program
{
static void Main(string[] args)
{
int m = int.Parse(Console.ReadLine());
string s = Console.ReadLine();
string[] ss = s.Split();
float[] arr = Array.ConvertAll<string, float>(ss, float.Parse);
Array.Sort(arr);
float sum = 0;
float result = 0;
for (int i = 0; i < arr.Length; i++)
{
sum += ((arr[i] / arr[m-1]) * 100);
}
result = sum / m;
Console.WriteLine(result);
}
}
}
Solution
float์ด๋ int๋ฅผ ๊ฐ์ด ๊ณ์ฐํ๋ คํจ...
์ด๋ฐ ์ฌ์ํ ์ค์๋.. ๊ธ์ง...
using System;
namespace ConsoleApp1
{
class Program
{
static void Main(string[] args)
{
int m = int.Parse(Console.ReadLine());
string s = Console.ReadLine();
string[] ss = s.Split();
float[] arr = Array.ConvertAll<string, float>(ss, float.Parse);
Array.Sort(arr);
float sum = 0;
float result = 0;
for (int i = 0; i < arr.Length; i++)
{
sum += ((arr[i] / arr[m-1]) * 100);
}
result = sum / m;
Console.WriteLine(result);
}
}
}
'๐ฉโ๐ปProgramming > Coding Test' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
[C#] [BOJ#4344] ํ๊ท ์ ๋๊ฒ ์ง (0) | 2022.07.30 |
---|---|
[C#] [BOJ#8958] OXํด์ฆ - ToCharArray (0) | 2022.07.30 |
[C#] [BOJ#3052] ๋๋จธ์ง - ์ค๋ณต ์ ๊ฑฐ (0) | 2022.07.30 |
[C#] [BOJ#2577] ์ซ์์ ๊ฐ์ (0) | 2022.07.30 |
[C#] [BOJ#2562] ์ต๋๊ฐ (0) | 2022.07.30 |
๋๊ธ