문제 (10950번)
두 정수 A와 B를 입력받은 다음, A+B를 출력하는 프로그램을 작성하시오.
입력
첫째 줄에 테스트 케이스의 개수 T가 주어진다.
각 테스트 케이스는 한 줄로 이루어져 있으며, 각 줄에 A와 B가 주어진다. (0 < A, B < 10)
출력
각 테스트 케이스마다 A+B를 출력한다.
풀이
코드
use std::io;
fn main() {
let mut num = String::new();
io::stdin()
.read_line(&mut num)
.expect("Cannot read num.");
let num: u32 = num.trim().parse().unwrap();
for _ in 1..=num {
let mut input = String::new();
io::stdin().read_line(&mut input).expect("Cannot read line.");
let input: Vec<&str> = input.split_whitespace().collect();
let a: u32 = input[0].trim().parse().unwrap();
let b: u32 = input[1].trim().parse().unwrap();
println!("{}", a+b);
}
}
해설
특이사항 없음
추가 학습
- 특이사항 없음
'컴퓨터 과학 > 자료구조, 알고리즘' 카테고리의 다른 글
[Rust로 백준 하루 하나] 3-4. 영수증 (0) | 2024.08.04 |
---|---|
[Rust로 백준 하루 하나] 3-3. 합 (0) | 2024.08.03 |
[Rust로 백준 하루 하나] 3-1. 구구단 (0) | 2024.07.30 |
[Rust로 백준 하루 하나] 2-7. 주사위 세개 (0) | 2024.07.29 |
[Rust로 백준 하루 하나] 2-6. 오븐 시계 (0) | 2024.07.29 |