Notice
Recent Posts
Recent Comments
Link
«   2025/08   »
1 2
3 4 5 6 7 8 9
10 11 12 13 14 15 16
17 18 19 20 21 22 23
24 25 26 27 28 29 30
31
Archives
Today
Total
관리 메뉴

코딩로그

[백준/BOJ/C++] 4458번 첫 글자를 대문자로 본문

YJ/C++

[백준/BOJ/C++] 4458번 첫 글자를 대문자로

Team DAON 2021. 11. 5. 14:51

[문제]

문장을 읽은 뒤, 줄의 첫 글자를 대문자로 바꾸는 프로그램을 작성하시오.

[입력]

첫째 줄에 줄의 수 N이 주어진다. 다음 N개의 줄에는 문장이 주어진다. 각 문장에 들어있는 글자의 수는 30을 넘지 않는다. 모든 줄의 첫 번째 글자는 알파벳이다.

[출력]

각 줄의 첫글자를 대문자로 바꾼뒤 출력한다.

[Source Code]

#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
using namespace std;

int main() {
	int test;
	cin >> test;
	cin.ignore();

	for(int i = 0; i < test; i++){
		string input;
		getline(cin, input);

		if(input[0] >= 'a' && input[0] <= 'z')
			input[0] = input[0] - 'a' + 'A';

		cout << input <<"\n";
	}
}

[결과 화면]