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++] 11319번 Count Me In 본문

YJ/C++

[백준/BOJ/C++] 11319번 Count Me In

Team DAON 2021. 11. 9. 16:14

[문제]

Given a sentence in English, output the counts of consonants and vowels.

Vowels are letters in [’A’,’E’,’I’,’O’,’U’,’a’,’e’,’i’,’o’,’u’].

[입력]

The test file starts with an integer S(1 ≤ S ≤ 100), the number of sentences.

Then follow S lines, each containing a sentence - words of length 1 to 20 separated by spaces. Every sentence will contain at least one word and be comprised only of characters [a-z][A-Z] and spaces. No sentence will be longer than 1000 characters.

[출력]

For each sentence, output the number of consonants and vowels on a line, separated by space.

[Source Code]

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

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

	for(int i = 0; i < num; i++){
		int con = 0, vow = 0;
		string input;
		getline(cin, input);
		for(int j = 0; j < input.length(); j++){
			if(input[j] == 'A' || input[j] == 'a' ||
				input[j] == 'E' || input[j] == 'e' ||
				input[j] == 'I' || input[j] == 'i' ||
				input[j] == 'O' || input[j] == 'o' ||
				input[j] == 'U' || input[j] == 'u')
				vow++;
			else if(input[j] != ' ')
				con++;
		}

		cout << con << " " << vow << "\n";
	}
}

[결과 화면]