fork download
  1. #include <iostream>
  2. #include <string>
  3. using namespace std;
  4.  
  5. int main() {
  6. string tekst;
  7. cout << "Podaj tekst: ";
  8. getline(cin, tekst); // wczytuje cały wiersz, łącznie ze spacjami
  9.  
  10. int licznik = 0;
  11. for (char znak : tekst) {
  12. if (znak == 'j') {
  13. licznik++;
  14. }
  15. }
  16.  
  17. cout << "Liczba liter 'j': " << licznik << endl;
  18. return 0;
  19. }
Success #stdin #stdout 0.01s 5252KB
stdin
jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj
stdout
Podaj tekst: Liczba liter 'j': 113