백준 BOJ C# 15552 빠른 A+B
2020. 1. 10. 16:44ㆍ백준 알고리즘 단계별/for 문
반응형
출제 링크 : https://www.acmicpc.net/problem/15552
코드
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
|
using System;
using static System.Console;
using System.Text;
using System.IO;
namespace baekjoon
{
class MainApp
{
static void Main(string[] args)
{
//입력 : T개의 개수 받아오기
int maxT = int.Parse(Console.ReadLine());
int[] aNum = new int[maxT];
int[] bNum = new int[maxT];
StringBuilder abNumbers = new StringBuilder();
//T줄 만큼 반복되고 A,B받아오기
for (int i = 0; i < maxT; i++)
{
string[] ab = Console.ReadLine().Split(); // 입력받을때 Split으로 잘라 배열로 만듬
aNum[i] = int.Parse(ab[0]);
bNum[i] = int.Parse(ab[1]);
}
//받아온 값 더하기
WriteLine(abNumbers.ToString());
}
}
}
|
이번 문제는 엄청 어려웠다...
C# 구문
StreamReader로 읽고, StringBuilder로 출력을 모아 놓았다가 그 String을 Console.WriteLine하는 방법이 있습니다. BufferedStream과 StringWriter로 조금 더 향상시킬 수 있는 것 같으나 자세한 것은 다른 분의 답변을 기다리겠습니다.
기존 for문 사용과 StringBuilder 을 활용해야되고 아직 사용하지 못한 StringReader을 통해 받아오지 못했다.
https://morm.tistory.com/28?category=724725
결국 구글링 끝에 찾아낸 해답... 밑에는 풀기 위해 찾았던 자료들을 모아두었다.
https://nowonbun.tistory.com/131
http://www.csharpstudy.com/Data/File-text.aspx
반응형