1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93
|
#include <iostream>
#include <string>
#include <vector>
#include <array>
#include <cmath>
char letters[] = {'a','b','c','d','e','f','g'};
char * tempArr;
char * pastArr;
std::vector<char * > deneme;
char s1[] = {'a', 'b'};
char s2[] = {'c', 'd'};
void calculateAllPossibilities(int depth, int lastDepth)
{
//depth 1 den baĆ¾layacak
for( int i = 0; i < sizeof(letters); i++ )
{
//
if ( depth != 1 && depth != lastDepth )
{
//
tempArr = new char[depth];
for( int j = 0; j < depth-1; j++ )
{
//
*tempArr = pastArr[j];
tempArr++;
}
*tempArr = letters[i];
for( int x = 0; x < depth; x++ )
{
//
std::cout << tempArr[x] << ",";
}
std::cout << std::endl;
delete pastArr;
pastArr = new char[depth];
for( int k = 0; k < depth; k++ )
{
//
*pastArr = tempArr[k];
pastArr++;
}
delete tempArr;
calculateAllPossibilities(depth + 1, lastDepth );
}
else if( depth == lastDepth )
{
//
tempArr = new char[depth];
for( int k = 0; k < depth - 1; k++ )
{
//
*tempArr = pastArr[k];
tempArr++;
}
*tempArr = letters[i];
for( int x = 0; x < depth; x++ )
{
//
std::cout << tempArr[x] << ",";
}
std::cout << std::endl;
deneme.push_back(tempArr);
delete tempArr;
}
else if( depth == 1 )
{
//
pastArr = new char[depth];
*pastArr = letters[i];
std::cout << pastArr[0] << std::endl;
delete tempArr;
calculateAllPossibilities(depth + 1, lastDepth );
}
}
}
int main()
{
calculateAllPossibilities(1,7);
std::cout << deneme[0][2];
return 0;
}
|