반응형
백준: 문자열분석
난이도: 브론즈2
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
using namespace std;
int main()
{
ios::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
string str;
int count = 0;
vector < pair<pair<int, int>, pair<int, int>>>v(101);
while(getline(cin, str, '\n'))
{
if (count == 101)
break;
for(int i=0;i<str.length();i++)
{
if (str[i] >= 'a' && str[i] <= 'z')
v[count].first.first++;
else if (str[i] >= 'A' && str[i] <= 'Z')
v[count].first.second++;
else if (str[i] >= '0' && str[i] <= '9')
v[count].second.first++;
else if (str[i] == ' ')
v[count].second.second++;
}
cout << v[count].first.first << " " << v[count].first.second << " " << v[count].second.first << " " << v[count].second.second << "\n";
count++;
}
return 0;
}
반응형
'Programming > Baekjoon' 카테고리의 다른 글
백준 7568 c++ (0) | 2022.01.21 |
---|---|
백준 1026 c++ (0) | 2022.01.21 |
백준 11656 c++ (0) | 2022.01.20 |
백준 10866 c++ (0) | 2022.01.20 |
백준 10845 c++ (0) | 2022.01.20 |