Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // PracticeOnlesson.cpp:
- //
- #include <iostream>
- #include <string>
- #include <time.h>
- using namespace std;
- int main()
- {
- string a;
- cin >> a;
- srand(time(NULL));
- int randomValues[5];
- int randNumsCounter = 0;
- while (randNumsCounter < 5)
- {
- int tmp = rand() % a.size();
- bool isMatch = false;
- for (int i = 0; i < 5; i++)
- {
- if (randomValues[i] == tmp)isMatch = true;
- }
- if (!isMatch)
- {
- randomValues[randNumsCounter] = tmp;
- randNumsCounter++;
- }
- }
- for (int i = 0; i < 5; i++)
- {
- a[randomValues[i]] = 'A';
- }
- cout << a << endl;
- }
Add Comment
Please, Sign In to add comment