백준/백준-C++

10820번: 문자열 분석

Beabletoet 2017. 6. 6. 00:21

#include<cstdio>

#include<iostream>

#include<string>

using namespace std;

int main()

{

string text;

while (getline(cin, text))

{

int ans[4] = { 0,0,0,0 };

for (int i = 0; i < text.size(); ++i)

if (text[i] >= 'a' && text[i] <= 'z')

++ans[0];

else if (text[i] >= 'A' && text[i] <= 'Z')

++ans[1];

else if (text[i] >= '0' && text[i] <= '9')

++ans[2];

else

++ans[3];

printf("%d %d %d %d\n", ans[0], ans[1], ans[2], ans[3]);

}

}