Advertisement
Guest User

Untitled

a guest
Mar 22nd, 2017
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.67 KB | None | 0 0
  1. #include "stdafx.h"
  2. #include <ctime>
  3. #include <iostream>
  4.  
  5. using namespace std;
  6. int main()
  7. {
  8. char answer;
  9. do{
  10. srand(time(NULL));
  11. const int str = 40;
  12. char* string = new char[str];
  13. cout << "Type string: ";
  14. cin.getline(string, str+1);
  15. /*for (int i = 0; i < str; ++i)
  16. {
  17. string[i] = rand() / 64 % 123;
  18. cout << string[i];
  19. }*/
  20. for (int j = 0; j < str; ++j)
  21. {
  22. if (string[j] == 'a' && string[j + 1] == 'b' && string[j + 2] == 'c')
  23. {
  24. string[j] = 'd';
  25. string[j + 1] = 'e';
  26. string[j + 2] = 'f';
  27. }
  28. cout << string[j];
  29. }
  30.  
  31. cout << "\nTry again? y/n\n";
  32. cin >> answer;
  33. } while (answer != 'n');
  34. return 0;
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement