#include <iostream>
#include <string>
int main()
{
std::string text;
std::cout << "Podaj tekst: ";
std::getline(std::cin, text);
int countA = 0, countB = 0, countC = 0;
for (char c : text)
switch (c)
case 'a':
++countA;
break;
case 'b':
++countB;
case 'c':
++countC;
}
std::cout << "Liczba liter 'a': " << countA << std::endl;
std::cout << "Liczba liter 'b': " << countB << std::endl;
std::cout << "Liczba liter 'c': " << countC << std::endl;
return 0;
" Life is not a problem to be solved but a reality to be experienced! "
© Copyright 2013 - 2024 KUDO.TIPS - All rights reserved.
#include <iostream>
#include <string>
int main()
{
std::string text;
std::cout << "Podaj tekst: ";
std::getline(std::cin, text);
int countA = 0, countB = 0, countC = 0;
for (char c : text)
{
switch (c)
{
case 'a':
++countA;
break;
case 'b':
++countB;
break;
case 'c':
++countC;
break;
}
}
std::cout << "Liczba liter 'a': " << countA << std::endl;
std::cout << "Liczba liter 'b': " << countB << std::endl;
std::cout << "Liczba liter 'c': " << countC << std::endl;
return 0;
}