백준
백준 4470 - 줄번호(C++)
공대생의 잡다한 사전
2023. 5. 18. 22:49
문제 링크입니다. https://www.acmicpc.net/problem/4470
4470번: 줄번호
텍스트에서 줄을 입력받은 뒤, 줄 번호를 출력하는 프로그램을 작성하시오.
www.acmicpc.net
주어진 문장 앞에 해당 문장의 줄번호를 추가로 출력해주는 문제입니다.
자세한 것은 코드를 참고해주세요
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <queue>
#include <vector>
#include <cstring>
#include <cmath>
using namespace std;
int N;
char arr[51];
int main(){
cin.tie(0);
cout.tie(0);
scanf("%d\n", &N);
for(int i = 1; i <= N; i++){
cin.getline(arr, 51);
cout << i << ". ";
for(int j = 0; j < strlen(arr); j++){
cout << arr[j];
}
cout << "\n";
}
return 0;
}
질문 및 조언은 댓글을 남겨주세요