#include <iostream>
#include <string>
#include <cctype>
int main()
{
std::string input;
std::cout << "Enter text: ";
std::getline(std::cin, input);
size_t num_uppers = 0, num_lowers = 0, num_digits = 0, num_graphs = 0, num_others = 0;
std::string uppers, lowers, digits, graphs, others;
for (size_t i = 0; i < input.size(); ++i) {
char c = input[i];
if (isupper(c)) {num_uppers++; uppers.push_back(c);}
else if (islower(c)) {num_lowers++; lowers.push_back(c);}
else if (isdigit(c)) {num_digits++; digits.push_back(c);}
else if (isgraph(c)) {num_graphs++; graphs.push_back(c);}
else {num_others++; others.push_back(c);}
}
std::cout << "N, Uppers: " << num_uppers << " - " << uppers << std::endl;
std::cout << "N, Lowers: " << num_lowers << " - " << lowers << std::endl;
std::cout << "N, Digits: " << num_digits << " - " << digits << std::endl;
std::cout << "N, Graphs: " << num_graphs << " - " << graphs << std::endl;
std::cout << "N, Others: " << num_others << " - " << "Oops!" << std::endl;
std::cin.ignore();
return 0;
}
Comments
Leave a comment