fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int ile(string s, char z)
  5. {
  6. int licznik=0;
  7. for(int i=0; i<s.size() ;i++)
  8. if (s[i]==z)
  9. licznik++;
  10.  
  11. return licznik;
  12. }
  13.  
  14. int pary(string s)
  15. {
  16. int licznik=0;
  17. for (int i=0; i<s.size()-1; i++)
  18. if (s[i]==s[i+1])
  19. licznik++;
  20.  
  21. return licznik;
  22. }
  23.  
  24.  
  25.  
  26. int main() {
  27. cout << pary("CATTCGAACGTCAAGCTTTCGAT") << endl;
  28.  
  29. cout << ile("CAGGTACTAGGAACGG", 'A') << endl;
  30. cout << ile("CAGGTACTAGGAACGG", 'C') << endl;
  31. cout << ile("CAGGTACTAGGAACGG", 'G') << endl;
  32. cout << ile("jdhsygeterdfshaiwn", 'e') << endl;
  33. return 0;
  34. }
Success #stdin #stdout 0.01s 5276KB
stdin
Standard input is empty
stdout
5
5
3
6
2