Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- int main()
- {
- std::string str;
- std::cout << "Enter your text: " << std::endl;
- std::getline(std::cin, str);
- int number_of_a(0);
- for (int i = 0; i < str.length(); i++)
- {
- number_of_a = (str.at(i)=='a') ? (number_of_a+1) : number_of_a;
- }
- std::cout << number_of_a << std::endl;
- system("pause");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement