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 stat[256]{ 0 };
- char ch;
- while (cin.get(ch) && ch != '@') {
- stat[unsigned(ch)]++;
- }
- int alpha = 0;
- int numeric = 0;
- int others = 0;
- cout << "\n--- stat ---" << endl;
- for (unsigned ch = 0; ch < 256; ch++) {
- if (ch >= 'A' && ch <= 'Z') {
- alpha += stat[ch];
- } else if (ch >= 'a' && ch <= 'z') {
- alpha += stat[ch];
- } else if (ch >= '0' && ch <= '9') {
- numeric += stat[ch];
- } else {
- others += stat[ch];
- }
- }
- cout << "alpha\t" << alpha << endl
- << "numeric\t" << numeric << endl
- << "others\t" << others << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement