Pagini recente » Cod sursa (job #680568) | Cod sursa (job #1649307) | Cod sursa (job #1612344) | Cod sursa (job #2023868) | Cod sursa (job #1188495)
#include<fstream>
using namespace std;
ifstream in("oras.in");
ofstream out("oras.out");
const int nmax = 206;
char mat[nmax][nmax];
int n;
void back(int k)
{
if(k==3)
{
mat[1][2] = mat[2][3] = mat[3][1] = 49;
return;
}
if(k==6)
{
mat[1][2] = mat[1][4] = mat[1][6] = mat[2][3] = mat[2][5] = mat[2][6] = mat[3][1] = mat[3][5] = mat[4][2] = mat[4][3] = mat[4][5] = mat[5][1] = mat[5][6] = mat[6][3] = mat[6][4] = 49;
return;
}
mat[k-1][k] = 49;
for(int i = 1; i<=k-2; i++)
{
mat[i][k-1] = mat[k][i] = 49;
}
back(k-2);
}
int main(){
int player_unu=0;
in>>n;
if(n==4)
{
out<<-1<<'\n';
return 0;
}
for(int i = 1; i<=n; i++)
{
for(int j = 1; j<=n; j++)
mat[i][j] = 48;
mat[i][n+1] = 10;
}
back(n);
for(int i = 1; i<=n; i++)
for(int j = 1; j<=n+1; j++)
out<<mat[i][j];
return player_unu;
}