Advertisement
Dawid_PAr

ZLICZANIElTER

Aug 27th, 2019
271
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.67 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3. using namespace std;
  4.  
  5. void zliczaczLiter(string tex)
  6. {
  7. size_t pos;
  8. int ilosc = 0;
  9. char l = 97;
  10. do
  11. {
  12. do
  13. {
  14. if((pos = tex.find(l, pos+1)) != string::npos) ilosc+=1;
  15. else
  16. {
  17. if(ilosc == 0) break; // BEZ TEGO WARUNKU WYPISUJE NORMALNIE WSZYSTKIE LITERY ORAZ ICH ILOSC, A Z NIM NIE DZIALA POPRAWNIE
  18. cout << l << " " << ilosc << endl;
  19. l+=1;
  20. ilosc = 0;
  21. }
  22. }while(pos != string::npos);
  23. }while(l <= 122);
  24. }
  25.  
  26. int main()
  27. {
  28. string tekst;
  29. getline(cin, tekst);
  30. zliczaczLiter(tekst);
  31.  
  32. return 0;
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement