Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* (1) Вводиться рядок. Знайти кількість малих латинських літер у рядку,
- кількість великих латинських літер, кількість цифр та розділових знаків.
- Скористатися функціями islower(), isupper(), isdigit(), ispuntc(). */
- #include <iostream>
- #include <string>
- #include <ctype.h>
- #include <iomanip>
- using namespace std;
- int main()
- {
- string line;
- int number_lower = 0, number_supper = 0, number_digit = 0, number_punct = 0;
- cout << "Enter the string: ";
- getline (cin,line);
- for (int i = 0; i < line.size(); i++)
- {
- if (islower(line[i]))
- number_lower++;
- else if (isupper(line[i]))
- number_supper++;
- else if (isdigit(line[i]))
- number_digit++;
- else if (ispunct(line[i]))
- number_punct++;
- }
- cout << "String has: \n";
- cout << "\tlower case letter " << number_lower << endl;
- cout << "\tsupper case letter " << number_supper << endl;
- cout << "\tdigit " << number_digit << endl;
- cout << "\tpunctuation " << number_punct << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement