Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int main(int argc, char const *argv[])
- {
- int ch;
- unsigned counter[256] = {0};
- while ((ch = cin.get()) > 0)
- {
- counter[ch]++;
- }
- unsigned count_alpha = 0;
- unsigned count_digit = 0;
- unsigned count_space = 0;
- unsigned count_other = 0;
- for (int i = 0; i < 256; i++)
- {
- if (isalpha(i))
- {
- count_alpha += counter[i];
- }
- else if (isdigit(i))
- {
- count_digit += counter[i];
- }
- else if (isspace(i))
- {
- count_space += counter[i];
- }
- else
- {
- count_space += counter[i];
- }
- }
- cout << "count_alpha = " << count_alpha << endl;
- cout << "count_digit = " << count_digit << endl;
- cout << "count_space = " << count_space << endl;
- cout << "count_other = " << count_other << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement