Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <vector>
- #include <iostream>
- using namespace std;
- int counter=0;
- void out(const vector<char> &array)
- {
- int count = 0;
- for (int i = 0; i < array.size(); i++)
- {
- if (array[i] == 's')
- count++;
- if (count == 2)
- {
- for (int j = 0; j < array.size(); j++)
- {
- cout << array[j];
- }
- counter++;
- cout << endl;
- break;
- }
- }
- }
- void loop(vector<char> array,int pos)
- {
- if (pos == array.size() - 1)
- {
- array[pos] = 's';
- out(array);
- array[pos] = 'w';
- out(array);
- array[pos] = 'o';
- out(array);
- array[pos] = 'j';
- out(array);
- }
- else
- {
- array[pos] = 's';
- loop(array, pos + 1);
- array[pos] = 'w';
- loop(array, pos + 1);
- array[pos] = 'o';
- loop(array, pos + 1);
- array[pos] = 'j';
- loop(array, pos + 1);
- }
- }
- int main()
- {
- int n;
- cout << "Задание 3" << endl << "Введите длину: " << endl;
- cin >> n;
- vector<char> array(n);
- loop(array, 0);
- cout <<"Общее число:"<< counter;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement