#include <iomanip>
#include <iostream>
#include <windows.h>
#include <cstdlib>
#include <cstdio>
#include <vector>
using namespace std;
void fitnessChart( vector< vector< vector< int > > > array, int & ) ;
int main( int argc, char * argv[ ] )
{
int vertices;
const int initial_value = 0 ;
int pop;
std:: cout << "Enter the number of vertices:" << std:: endl ;
std:: cin >> vertices;
std:: cout << "Enter the size of the population:" << std:: endl ;
std:: cin >> pop;
std:: vector < int > sub_sub_array( vertices, initial_value) ;
std:: vector < std:: vector < int > > sub_array( vertices, sub_sub_array) ;
std:: vector < std:: vector < std:: vector < int > > > array( pop, sub_array) ;
int e;
for ( int i = 0 ; i < pop; ++ 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 < pop; ++ 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 < array.size ( ) ; i++ )
{
fitnessChart( array, i) ;
}
system ( "pause" ) ;
}
void fitnessChart( vector< vector< vector< int > > > array, int & i)
{
int count= 0 , match, first, j= 0 , k= 1 ;
for ( k; k < array[ k] .size ( ) ; k++ )
{
match = array[ i] [ j] [ k] ;
first = j;
j = k;
for ( k; k < array[ k] .size ( ) ; k++ )
{
if ( array[ i] [ j] [ k+ 1 ] == match)
{
if ( array[ i] [ k+ 1 ] [ first] == match)
{
count++ ;
}
}
}
}
cout << count << endl;
}
I2luY2x1ZGUgPGlvbWFuaXA+CiNpbmNsdWRlIDxpb3N0cmVhbT4KI2luY2x1ZGUgPHdpbmRvd3MuaD4KI2luY2x1ZGUgPGN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AgICAgICAgICAgIGlmIChqID09IGspCiAgICAgICAgICAgICAgICB7CiAgICAgICAgICAgICAgICAgICAgYXJyYXlbaV1bal1ba10gPSA5OwogICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgZWxzZQogICAgICAgICAgICAgICAgewogICAgICAgICAgICAgICAgICAgIGFycmF5W2ldW2pdW2tdID0gZTsKICAgICAgICAgICAgICAgICAgICBhcnJheVtpXVtrXVtqXSA9IGU7CiAgICAgICAgICAgICAgICB9CgogICAgICAgICAgICB9CiAgICAgICAgfQogICAgfQoKCgovLyBQcmludCBvdXQgdGhlIGZ1bGwgYXJyYXkgY29udGVudHMKICAgIGZvcihpbnQgaSA9IDA7IGkgPCBwb3A7ICsraSkKICAgIHsKICAgICAgICBmb3IoaW50IGogPSAwOyBqIDwgdmVydGljZXM7ICsraikKICAgICAgICB7CiAgICAgICAgICAgIGZvcihpbnQgayA9IDA7IGsgPCB2ZXJ0aWNlczsgKytrKQogICAgICAgICAgICB7CiAgICAgICAgICAgICAgICBpZihqIT1rKQogICAgICAgICAgICAgICAgewogICAgICAgICAgICAgICAgICAgIHN0ZDo6Y291dCA8PCAiICIgPDwgYXJyYXlbaV1bal1ba10gPDwgIiAiOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgZWxzZQogICAgICAgICAgICAgICAgICAgIHN0ZDo6Y291dCA8PCAiIC0gIjsKICAgICAgICAgICAgfQogICAgICAgICAgICBzdGQ6OmNvdXQgPDwgIlxuIjsKICAgICAgICB9CiAgICAgICAgc3RkOjpjb3V0IDw8ICJcbiI7CiAgICB9CgogICAgZm9yKGludCBpID0gMDsgaSA8IGFycmF5LnNpemUoKTsgaSsrKQogICAgewogICAgICAgIGZpdG5lc3NDaGFydChhcnJheSwgaSk7CiAgICB9CgogICAgc3lzdGVtICgicGF1c2UiKTsKfQoKdm9pZCBmaXRuZXNzQ2hhcnQodmVjdG9yPHZlY3Rvcjx2ZWN0b3I8aW50PiA+ID4gYXJyYXksIGludCYgaSkKewogICAgaW50IGNvdW50PTAsIG1hdGNoLCBmaXJzdCwgaj0wLCBrPTE7CgogICAgZm9yKGs7IGsgPCBhcnJheVtrXS5zaXplKCk7IGsrKykKICAgIHsKICAgICAgICBtYXRjaCA9IGFycmF5W2ldW2pdW2tdOwogICAgICAgIGZpcnN0ID0gajsKICAgICAgICBqID0gazsKCiAgICAgICAgZm9yKGs7IGsgPCBhcnJheVtrXS5zaXplKCk7IGsrKykKICAgICAgICB7CiAgICAgICAgICAgIGlmIChhcnJheVtpXVtqXVtrKzFdID09IG1hdGNoKQogICAgICAgICAgICB7CiAgICAgICAgICAgICAgICBpZiAoYXJyYXlbaV1baysxXVtmaXJzdF0gPT0gbWF0Y2gpCiAgICAgICAgICAgICAgICB7CiAgICAgICAgICAgICAgICAgICAgY291bnQrKzsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgfQogICAgICAgIH0KICAgIH0KICAgIGNvdXQgPDwgY291bnQgPDwgZW5kbDsKfQo=
compilation info
prog.cpp:3:21: error: windows.h: No such file or directory
prog.cpp: In function ‘int main(int, char**)’:
prog.cpp:70: warning: comparison between signed and unsigned integer expressions
prog.cpp:75: warning: ignoring return value of ‘int system(const char*)’, declared with attribute warn_unused_result
prog.cpp: In function ‘void fitnessChart(std::vector<std::vector<std::vector<int, std::allocator<int> >, std::allocator<std::vector<int, std::allocator<int> > > >, std::allocator<std::vector<std::vector<int, std::allocator<int> >, std::allocator<std::vector<int, std::allocator<int> > > > > >, int&)’:
prog.cpp:82: warning: statement has no effect
prog.cpp:82: warning: comparison between signed and unsigned integer expressions
prog.cpp:88: warning: statement has no effect
prog.cpp:88: warning: comparison between signed and unsigned integer expressions
stdout