728x90
C#
브4 1330 두 수 비교하기
내 코드
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 | using System; namespace Baekjoon { class Program { static void Main() { string s = Console.ReadLine(); string[] ss = s.Split(); int a, b; a = int.Parse(ss[0]); b = int.Parse(ss[1]); if (a>b) { Console.Write(">"); } else if (a<b) { Console.Write("<"); } else { Console.Write("=="); } } } } | cs |
브1 1546 평균
내 코드
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | using System; using System.Linq; namespace Baekjoon { class Program { static void Main() { int num = int.Parse(Console.ReadLine()); int[] gradeArr = Array.ConvertAll(Console.ReadLine().Split(), s => int.Parse(s)); double[] fixedGrade = new double[num]; int maxGrade = gradeArr.Max(); for (int i = 0; i < num; i++) { fixedGrade[i] = (double)gradeArr[i] / maxGrade * 100; } double sumFixedGrade = fixedGrade.Sum(); Console.WriteLine(sumFixedGrade/num); } } } | cs |
브3 2438 별 찍기 - 1
내 코드
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | using System; namespace Baekjoon { class Program { static void Main() { int num = int.Parse(Console.ReadLine()); for (int i = 0; i < num; i++) { for (int j=0;j<=i;j++) { Console.Write("*"); } Console.WriteLine(); } } } } | cs |
브3 2439 별 찍기 - 2
내 코드
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | using System; namespace Baekjoon { class Program { static void Main() { int num = int.Parse(Console.ReadLine()); for (int i = 0; i < num; i++) { for (int j=0;j<num-1-i;j++) { Console.Write(" "); } for (int j=0;j<=i;j++) { Console.Write("*"); } Console.WriteLine(); } } } } | cs |
브5 2475 검증수
내 코드
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | using System; using System.Linq; namespace Baekjoon { class Program { static void Main() { int[] numArr = Array.ConvertAll(Console.ReadLine().Split(), s => int.Parse(s)); double[] squareNumArr = new double[numArr.Length]; for (int i=0;i<squareNumArr.Length;i++) { squareNumArr[i] = Math.Pow(numArr[i], 2); } Console.WriteLine(squareNumArr.Sum()%10); } } } | cs |
브5 2557 Hello World
내 코드
1 2 3 4 5 6 7 8 9 10 11 | using System; namespace Baekjoon { class Program { static void Main() { Console.Write("Hello World!"); } } } | cs |
728x90




최근댓글