Advertisement
Guest User

Untitled

a guest
Jul 7th, 2015
291
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.11 KB | None | 0 0
  1. /* (1) Вводиться рядок. Знайти кількість малих латинських літер у рядку,
  2. кількість великих латинських літер, кількість цифр та розділових знаків.
  3. Скористатися функціями islower(), isupper(), isdigit(), ispuntc(). */
  4.  
  5. #include <iostream>
  6. #include <string>
  7. #include <ctype.h>
  8. #include <iomanip>
  9.  
  10. using namespace std;
  11.  
  12. int main()
  13. {
  14. string line;
  15. int number_lower = 0, number_supper = 0, number_digit = 0, number_punct = 0;
  16. cout << "Enter the string: ";
  17. getline (cin,line);
  18. for (int i = 0; i < line.size(); i++)
  19. {
  20. if (islower(line[i]))
  21. number_lower++;
  22. else if (isupper(line[i]))
  23. number_supper++;
  24. else if (isdigit(line[i]))
  25. number_digit++;
  26. else if (ispunct(line[i]))
  27. number_punct++;
  28. }
  29. cout << "String has: \n";
  30. cout << "\tlower case letter " << number_lower << endl;
  31. cout << "\tsupper case letter " << number_supper << endl;
  32. cout << "\tdigit " << number_digit << endl;
  33. cout << "\tpunctuation " << number_punct << endl;
  34.  
  35. return 0;
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement