fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. // zdefiniuj funkcję
  5. int ile(string s, char z) {
  6. int ile = 0;
  7. for (int i = 0; i < s.size(); i++)
  8. if (s[i] == z)
  9. ile++;
  10. return ile;
  11. }
  12.  
  13. int main() {
  14. // sprawdź działanie funkcji
  15. cout << ile("CAATAAAAAT", 'T') << endl;
  16. cout << ile("CAATAAAAAT", 'A') << endl;
  17. cout << ile("CAATAAAAAT", 'C') << endl;
  18. cout << ile("TGATATTCGATGTGAAAAAT", 'A') << endl;
  19. cout << ile("TGATATTCGATGTGAAAAAT", 'C') << endl;
  20. cout << ile("TGATATTCGATGTGAAAAAT", 'G') << endl;
  21. cout << ile("TGATATTCGATGTGAAAAAT", 'T') << endl;
  22. return 0;
  23. }
  24.  
Success #stdin #stdout 0.01s 5320KB
stdin
Standard input is empty
stdout
2
7
1
8
1
4
7