Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- // #include <algorithm>
- #include <vector>
- #include <string>
- using namespace std;
- string CharsToString(char a, char b, char c, char d);
- bool CharFilter(char a, char b);
- int main(int argc, char** argv) {
- setlocale(LC_ALL,"");
- char abcd[4] = {'a','b','c','d'};
- vector<char> cv;
- vector<string> csv;
- for(char a='a'; a<='d'; a++) {
- if(a =='b' || a=='c'){ // rossz esetek szűrése
- continue;
- }
- for(char b='a'; b<='d'; b++) {
- if(CharFilter(a,b)){
- continue;
- }
- for(char c='a'; c<='d'; c++) {
- if(CharFilter(b,c)){
- continue;
- }
- for(char d='a'; d<='d'; d++) {
- if(CharFilter(c,d)){
- continue;
- }
- string newS = CharsToString(a,b,c,d);
- csv.push_back(newS);
- if(newS == "acbd"){
- cout << newS << endl;
- }
- }
- }
- }
- }
- /* Ezt ellenőrzéshez használtam!
- if ( find(csv.begin(), csv.end(), "acbd") != csv.end() )
- cout << "Létezik! " << sum << endl;
- else
- cout << "Nem létezik!" << endl;
- */
- return 0;
- }
- bool CharFilter(char a, char b){ // rossz esetek szűrése
- if(b=='a' && a=='a'){
- return true;
- }else if(b=='b' && (a=='b' || a!='c')){
- return true;
- }else if(b=='c' && (a=='c' || a!='a')){
- return true;
- }else if(b=='d' && a=='d'){
- return true;
- }else{
- return false;
- }
- }
- string CharsToString(char a, char b, char c, char d){
- string aS;
- aS.push_back(a);
- string bS;
- bS.push_back(b);
- string cS;
- cS.push_back(c);
- string dS;
- dS.push_back(d);
- return aS+bS+cS+dS;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement