Advertisement
shinema

Untitled

Oct 12th, 2018
187
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.50 KB | None | 0 0
  1. #include <iostream>
  2. #include<string>
  3. #include<fstream>
  4. #include<algorithm>
  5. using namespace std;
  6. int main(){
  7. int risultato=0;
  8. ifstream in;
  9. ofstream ou;
  10. in.open("input.txt");
  11. string a;
  12. getline(in,a);
  13. long long contatore=0;
  14. for(int i=0;i<a.length();i++){
  15. if(a.compare(i,5,"hello")==0){
  16. contatore++;
  17. i+=4;
  18. }
  19. if(a.compare(i,5,"world")==0){
  20. risultato+=contatore;
  21. i+=4;
  22. }
  23. }
  24. ou.open("output.txt");
  25. ou<<risultato;
  26. return 0;
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement