using namespace std;
int mat[20][20];
int c,p,k,s,i,j,dim;
#define n 9
void imprimir()
{
cout<<"\n";
for (i=0; i<=n-1;i++)
{
for (j=0;j<=n-1;j++)
{
cout<<"\t"<<mat[i][j];
}
cout<<"\n";
}
}
void entrada_2( )
{
cout<<"ENTRADA N° 2 ";
cout<<"\n";
c=n;
s=0;
dim=(n*n)-1;
i=0;
k=0;
//cout<<"\nn="<<n;
for (k=0; k<=n; k++)
{
//cout<<"\nc="<<c;
if (c==n)
{
for (i=n-1; i>=0; i--)
{
s=s+1;
mat[i][j]=s;
//cout<<"\t"<<mat[i][j];
c=c-1;
}
j=j+1;
}
if (c==0)
{
for (i=0; i<=n-1;i++)
{
s=s+1;
mat[i][j]=s;
//cout<<"\t"<<mat[i][j];
c=c+1;
}
//cout<<"\n";
j=j+1;
}
}
}
void entrada_3()
{
cout<<"ENTRADA N° 3 ";
cout<<"\n";
//n=9;
c=0;
s=0;
dim=(n*n)-1;
i=0;
//cout<<"\nn="<<n;
for (k=0; k<=n; k++)
{
if (c==0)
{
for (j=0; j<=(n-1); j++)
{
s=s+1;
mat[i][j]=s;
//cout<<"\t"<<mat[i][j];
c=c+1;
}
i=i+1;
}
if (c==(n))
{
//cout<<"\n";
//i=i+1;
for (j=n-1; j>=0;j--)
{
s=s+1;
mat[i][j]=s;
//cout<<"\t"<<mat[i][j];
c=c-1;
}
//cout<<"\n";
i=i+1;
}
}
}
void entrada_5( )
{
cout<<"ENTRADA N° 5 ";
cout<<"\n";
c=n;
s=0;
dim=(n*n)-1;
i=0;
k=0;
//cout<<"\nn="<<n;
for (k=0; k<=n; k++)
{
//cout<<"\nc="<<c;
if (c==n)
{
for (j=n-1; j>=0; j--)
{
s=s+1;
mat[i][j]=s;
//cout<<"\t"<<mat[i][j];
c=c-1;
}
i=i+1;
}
if (c==0)
{
for (j=0; j<=n-1;j++)
{
s=s+1;
mat[i][j]=s;
//cout<<"\t"<<mat[i][j];
c=c+1;
}
//cout<<"\n";
i=i+1;
}
}
}
void entrada_6()
{
//Imprimir();
cout<<"ENTRADA N° (6) ";
cout<<"\n";
c=0;
s=0;
for (i=0; i<=n; i++)
{
if (c==n)
{
//cout<<"c="<<c<<"n"<<n<<"i"<<i<<"="<<mat[0][1];
}
for (j=n-1; j>=0; j--)
{
s=s+1;
mat[i][j]=s;
c=c+1;
//cout<<"\t"<<mat[i][j];
}
}
}
void entrada_7( )
{
cout<<"ENTRADA N° 7 ";
cout<<"\n";
c=n;
s=-3;
dim=(n*n)-1;
i=0;
k=0;
j=n;
//cout<<"\nn="<<n;
for (k=0; k<=n; k++)
{
//cout<<"\nc="<<c;
if (c==n)
{
for (i=n-1; i>=0; i--)
{
s=s+1;
mat[i][j]=s;
//cout<<"\t"<<mat[i][j];
c=c-1;
}
j=j-1;
}
if (c==0)
{
for (i=0; i<=n-1;i++)
{
s=s+1;
mat[i][j]=s;
//cout<<"\t"<<mat[i][j];
c=c+1;
}
//cout<<"\n";
j=j-1;
}
}
}
void entrada_10()
{
//Imprimir();
cout<<"ENTRADA N° (10) ";
cout<<"\n";
c=0;
s=0;
for (j=0; j<=n; j++)
{
if (c==n)
{
//cout<<"c="<<c<<"n"<<n<<"i"<<i<<"="<<mat[0][1];
}
for (i=n-1; i>=0; i--)
{
s=s+1;
mat[i][j]=s;
c=c+1;
//cout<<"\t"<<mat[i][j];
}
}
}
void entrada_14()
{
//Imprimir();
cout<<"ENTRADA N° (14) ";
cout<<"\n";
c=0;
s=0;
for (j=n-1; j>=0; j--)
{
if (c==n)
{
//cout<<"c="<<c<<"n"<<n<<"i"<<i<<"="<<mat[0][1];
}
for (i=n-1; i>=0; i--)
{
s=s+1;
mat[i][j]=s;
c=c+1;
//cout<<"\t"<<mat[i][j];
}
}
}
void entrada_15()
{
//Imprimir();
cout<<"ENTRADA N° (15) ";
cout<<"\n";
cout<<"----------------------------------------------------";
cout<<"\n";
c=0;
s=0;
for (i=n-1; i>=0; i--)
{
if (c==n)
{
//cout<<"c="<<c<<"n"<<n<<"i"<<i<<"="<<mat[0][1];
}
for (j=n-1; j>=0; j--)
{
s=s+1;
mat[i][j]=s;
c=c+1;
//cout<<"\t"<<mat[i][j];
}
}
}
int main(void)
{
int MATRIX;
cout<<"N="<<n;
cout<<"\n";
//entrada_8();
MATRIX=14;
if (MATRIX==2)
{
entrada_2();
}
if (MATRIX==3)
{
entrada_3();
}
if (MATRIX==5)
{
entrada_5();
}
if (MATRIX==6)
{
entrada_6();
}
if (MATRIX==7)
{
entrada_7();
}
if (MATRIX==10)
{
entrada_10();
}
if (MATRIX==14)
{
entrada_14();
}
if (MATRIX==15)
{
entrada_15();
}
//entrada_2();
//entrada_3();
// entrada_5();
//entrada_6();
//entrada_7();
//entrada_14();
//entrada_10();
//entrada_14();
//entrada_15();
imprimir();
}
No hay comentarios:
Publicar un comentario