반응형
문제
26574번: Copier
Your copier broke down last week, and you need to copy a list of numbers for a class project due tomorrow! Luckily, you can use your computer to copy the numbers for you. Given a list of numbers, each on their own line, print out the number, a space, and t
www.acmicpc.net
풀이
문제를 번역해보면, n개의 숫자가 들어오는데 이 숫자를 한번씩 더 출력하면 되는 문제입니다.
입출력과 반복문만 사용하여 간단하게 풀이할 수 있습니다.
마지막 줄에 endl은 "\n"과 같은 역할을 합니다.
#include <iostream>
using namespace std;
int main() {
int n;
cin >> n;
for (int i = 0; i < n; i++) {
int copy;
cin >> copy;
cout << copy << " " << copy << endl;
}
return 0;
}
반응형
'📊 알고리즘' 카테고리의 다른 글
[백준] 26545 - Mathematics (0) | 2023.01.03 |
---|---|
[백준] 15311 - 약 팔기 (0) | 2023.01.02 |
[백준] 5988 - 홀수일까 작수일까 (0) | 2022.12.31 |
[백준] 26766 - Serca (0) | 2022.12.30 |
[백준] 1789 - 수들의 합 (0) | 2022.12.29 |