백준 11720 숫자의 합
Console Programming/C# Console 2019. 10. 1. 15:41
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 _11720
{
class Program
{
static void Main(string[] args)
{
int input = int.Parse(Console.ReadLine());
string str = Console.ReadLine();
int[] num = new int[input];
int sum = 0;
for (int j = 0; j < input; j++)
{
num[j] = Convert.ToInt32(str[j])-48;
}
for (int i = 0; i < input; i++)
{
sum = sum + num[i];
}
Console.WriteLine(sum);
}
}
}
http://colorscripter.com/info#e" target="_blank" style="color:#e5e5e5text-decoration:none">Colored by Color Scripter
|
'Console Programming > C# Console' 카테고리의 다른 글
9일차 메서드의 정의(4) 문자1개를 받아 아스키 코드로 출력 (0) | 2019.10.03 |
---|---|
9일차 메서드의 정의(3) 짝수이면 True를 반환 (0) | 2019.10.03 |
9일차 메서드의 정의(2) -홀수,짝수 반환 (0) | 2019.10.01 |
9일차 메서드의 정의(1) -문자열뒤에 123을 붙여 출력 (0) | 2019.10.01 |
8일차 WOW 진영, 종족, 직업 선택 Enum type활용 (0) | 2019.10.01 |