silvery_raksha
2012-07-06 19:30:48 UTC
#include "stdafx.h"
#include
#include
#include
#include
using namespace std;
void fitnessChart(vector
int main(int argc, char* argv[])
{
int vertices;
const int initial_value = 0;
int i;
std::cout << "Enter the number of vertices:" << std::endl;
std::cin >> vertices;
std::cout << "Enter the size of the population:" << std::endl;
std::cin >> i;
std::vector
std::vector
std::vector
int e;
for(int i = 0; i < vertices; ++i)
{
for(int j = 0; j < vertices; ++j)
{
for(int k = 0; k < vertices; ++k)
{
e = rand() %2;
if (j == k)
{
array[i][j][k] = 9;
break;
}
else
{
array[i][j][k] = e;
array[i][k][j] = e;
}
}
}
}
// Print out the full array contents
for(int i = 0; i < vertices; ++i)
{
for(int j = 0; j < vertices; ++j)
{
for(int k = 0; k < vertices; ++k)
{
if(j!=k)
{
std::cout << " " << array[i][j][k] << " ";
}
else
std::cout << " - ";
}
std::cout << "\n";
}
std::cout << "\n";
}
for(int i = 0; i < vertices; i++)
{
fitnessChart(array, vertices, i);
}
system ("pause");
}
void fitnessChart(vector
{
int count=0, match, j=0, k=1;
for(k; k < vertices; k++)
{
match = array[i][j][k];
j=k;
for(k; k < vertices; k++)
{
if (array[i][j][k+1] == match)
{
if (array[i][j][k+1] == match)
{
count++;
}
}
}
}
cout << count << endl;
}