10824 c++
-
10824) 네 수 c++백준코딩일기 2020. 12. 1. 11:55
문제 ) www.acmicpc.net/problem/10824 10824번: 네 수 첫째 줄에 네 자연수 A, B, C, D가 주어진다. (1 ≤ A, B, C, D ≤ 1,000,000) www.acmicpc.net 풀이 ) 예제 입력으로 문제를 생각해보면, 10, 20, 30, 40 을 입력받아서 A 와 B 를 붙인 수 = 1020 이고, C 와 D 를 붙인 수는 = 3040 으로 이 둘의 합은 1020 + 3040 = 4060 이 된다. 1. A 와 B 를 붙인 수를 만들기 위해 먼저 A 와 B 를 문자열로 바꾸어서 두개를 합해준다. to_string(A) + to_string(B) => 문자열끼리 더하게 되면 앞에 문자열 뒤에 붙인 문자열이 붙어서 1020 으로 만들어진다. 2. A, B, C, ..