본문 바로가기
백준 문제 해설

백준 18409 母音を数える (Counting Vowels)

by toomanysegtrees 2022. 11. 4.

산학협력 expo 모두 마무리 되었다 결과는 인기상 행복하다

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

 

18409번: 母音を数える (Counting Vowels)

長さ N の英小文字からなる文字列 S が与えられる.S のうち母音字の個数,つまり a,i,u,e,o の個数の総和を求めよ.

www.acmicpc.net

풀이

문자열의 문자 하나 하나를 탐색하며 모음이라면 출력값에 1을 더해준다

 

시간 복잡도 : $O(N)$

소요 시간 : 1분

아쉬운 점 : 앞으로 또 힘내자

전체적인 감상 : 화이팅

/* basic setup {{{ */
#include<bits/stdc++.h>
#define ff first
#define ss second
#define pb push_back
#define sz(x) ((int)x.size())
#define all(x) x.begin(),x.end()
#define compress(x) sort(all(x)), x.erase(unique(all(x)), x.end())
#define fast_io ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef const int ci;
const int MOD = 1e9+7;
const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3f;
/*}}}*/

int main(){
	fast_io;
	int n;
	string s1;
	cin>>n>>s1;
	n = 0;
	for(char c : s1) if(c == 'a'||c=='e'||c=='i'||c=='o'||c=='u') n++;
	cout<<n;
	cout<<'\n';
}

'백준 문제 해설' 카테고리의 다른 글

백준 4179 불!  (0) 2022.11.08
백준 24751 Betting  (0) 2022.11.08
백준 15749 Snow Boots  (0) 2022.11.06
백준 25704 출석 이벤트  (0) 2022.11.05
백준 4589 Gnome Sequencing  (0) 2022.11.03
백준 23235 The Fastest Sorting Algorithm In The World  (0) 2022.11.02
백준 17356 욱 제  (0) 2022.11.01
백준 5524 입실 관리  (1) 2022.10.31