백준 10953번 (A+B – 6, C++) [BAEKJOON]

목차 테이블

A+B – 6

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

시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초256 MB37355249912200768.053%

문제

두 정수 A와 B를 입력받은 다음, A+B를 출력하는 프로그램을 작성하시오.

입력

첫째 줄에 테스트 케이스의 개수 T가 주어진다.

각 테스트 케이스는 한 줄로 이루어져 있으며, 각 줄에 A와 B가 주어진다.

A와 B는 콤마(,)로 구분되어 있다. (0 < A, B < 10)

출력

각 테스트 케이스마다 A+B를 출력한다.

예제 입력 1

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
5
1,1
2,3
3,4
9,8
5,2
5 1,1 2,3 3,4 9,8 5,2
5
1,1
2,3
3,4
9,8
5,2

예제 출력 1

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
2
5
7
17
7
2 5 7 17 7
2
5
7
17
7

출처

비슷한 문제

알고리즘 분류


통과된 코드

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
#include <iostream>
#include <cstdlib>
using namespace std;
int N, A, B;
string str;
int main()
{
ios_base::sync_with_stdio(false); // scanf와 동기화를 비활성화
// cin.tie(null); 코드는 cin과 cout의 묶음을 풀어줍니다.
cin.tie(NULL);
cout.tie(NULL);
cin >> N;
for (int i = 0; i < N; i++) {
cin >> str;
A = atoi(str.substr(0, 1).c_str());
B = atoi(str.substr(2, 1).c_str());
cout << A + B << "\n";
}
return 0;
}
#include <iostream> #include <cstdlib> using namespace std; int N, A, B; string str; int main() { ios_base::sync_with_stdio(false); // scanf와 동기화를 비활성화 // cin.tie(null); 코드는 cin과 cout의 묶음을 풀어줍니다. cin.tie(NULL); cout.tie(NULL); cin >> N; for (int i = 0; i < N; i++) { cin >> str; A = atoi(str.substr(0, 1).c_str()); B = atoi(str.substr(2, 1).c_str()); cout << A + B << "\n"; } return 0; }
#include <iostream>
#include <cstdlib>

using namespace std;

int N, A, B;
string str;

int main()
{
    ios_base::sync_with_stdio(false); // scanf와 동기화를 비활성화
    // cin.tie(null); 코드는 cin과 cout의 묶음을 풀어줍니다.
    cin.tie(NULL);
    cout.tie(NULL);

    cin >> N;
    for (int i = 0; i < N; i++) {
        cin >> str;
        A = atoi(str.substr(0, 1).c_str());
        B = atoi(str.substr(2, 1).c_str());    
        cout << A + B << "\n";
    }

    return 0;
}

댓글 달기

이메일 주소는 공개되지 않습니다. 필수 필드는 *로 표시됩니다