# [gecode-users] generation of a solution with success but no display at the console

Thu Jul 4 04:20:46 CEST 2013

```hi every one!

i m new with gecode and this is my first model, it consists in displaying
the following result :

2 19 22 12 10
11 13 18 17  6
21 16  1  7 20
8 14 15 24  4
23  3  9  5 25
CSTE_65:65

so this is my code :
#include <gecode/int.hh>
#include <gecode/driver.hh>
#include <gecode/minimodel.hh>
#include <gecode/search.hh>

using namespace Gecode;

class E1 : public Space {
private :
static const int n =5;
protected:

IntVarArray v1;

IntVar v2;

public:

E1(void) : v1(*this, n*n,1,n*n), v2(*this,n*(n*n+1)/2,n*(n*n+1)/2){
distinct (*this, v1);
IntVarArgs rowArray  (*this,n , 1, n);
IntVarArgs  colArray  (*this,n , 1, n);
IntVarArgs diag1Array (*this,n , 1, n);
IntVarArgs diag2Array (*this,n , 1, n);

//IntVarArgs sumConstraints ;

for (int i =0; i<n;i++)
{
for (int j=0; j<n; j++)
{
rowArray[j]= v1[i*n+1];
colArray[j]= v1[j*n+1];
}
// rel (*this, sum(rowArray),IRT_EQ, v2);
//  rel ( *this , sum(colArray), IRT_EQ ,v2);

linear( *this , rowArray, IRT_EQ, v2);
linear( *this , colArray, IRT_EQ, v2);
diag1Array[i]=v1[i * n + i];
diag2Array[i]= v1[i*n+n-i-1];
}

//rel(*this , sum(diag1Array), IRT_EQ,v2);
//rel(*this, sum(diag2Array), IRT_EQ,v2);

linear( *this , diag1Array, IRT_EQ, v2);
linear( *this , diag2Array, IRT_EQ, v2);

// post branching
branch(*this, v1, INT_VAR_SIZE_MIN(), INT_VAL_MIN());

}
// search support
E1(bool share, E1& s) : Space(share, s) {
v1.update(*this, share, s.v1);
}

virtual Space* copy(bool share) {
return new E1(share,*this);
}

// print solution
void print(void) const  {
for(int i = 0; i < n; i++) {
for(int j = 0; j < n; j++) {
v1[i * n + j];
std::cout << v1[i * n + j] << std::endl;
}
}
}

};
// main function
int main(int argc, char* argv[]) {
// create model and search engine
E1* m = new E1;
DFS<E1> e(m);
delete m;
// search and print all solutions
while (E1* s = e.next()) {
s->print(); delete s;
}
return 0;
}

my problem is that when i generat the solution i do it successfly but when
i use the command prompt to execute the executable the console displays
nothing
so please if any one have any idea obout this i will be so greatful

thanks very much for any help