남영운 :: C# 백준 2953 나는 요리사다(19.10.17)

C# 백준 2953 나는 요리사다(19.10.17)

Console(콘솔)/알고리즘 2019. 10. 17. 18:13

https://www.acmicpc.net/problem/2953

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
29
30
31
32
33
34
using System;
 
namespace Syntax
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] arr = new int[5];
            int a = 0;
            for (int i = 0; i < 5; i++)
            {
                int sum = 0;
                string[] str = Console.ReadLine().Split(' ');
                int[] input = new int[str.Length];
                for (int j = 0; j < input.Length; j++)
                {
                    input[j] = int.Parse(str[j]);
                    sum = sum + input[j];
                }
                arr[i] = sum;
            }
            for (int i = 0; i < arr.Length; i++)
            {
                if(arr[a] < arr[i])
                {
                    a = i;
                }
            }
            Console.WriteLine($"{a+1} {arr[a]}");
        }
    }
}
 
http://colorscripter.com/info#e" target="_blank" style="color:#4f4f4ftext-decoration:none">Colored by Color Scripter
 

: