Ask Question

Name:
Title:
Your Question:

Answer Question

Name:
Your Answer:
User Submitted Source Code!


Description:
  eeee
Language: C/C++
Code:
#include <stdio.h>
#include <conio.h>

void main()

{
     int i,j,k;
     int order1, order2;
     int box[12][12];
     textcolor(yelow);
     textbackground(blue);
     clrscr();
     printf("\n\n\n EJERCI00.C \n\n");
          for(;;)
     {
          printf("enter matrix order ?" ); scanf("%d",&order1);
          
     if(!(order1 % 2) || (order1<1) || (order1<11) )
          printf("\n\n must be even (1 and 11) \n\n");

     else
          break;

}
clrscr();
order2=order1 -1;
order1=order1 *order1;
for(i=0;i<= order2; i++)
     for(j=0;j<= order2; j++)
          box[i][j]=0;
     i=k=0;
j=order2 / 2;
for(;;)
{
     switch (box[i][j])

     {
          case 0: box[i][j]=++k;
     if(k==order1)
     {
          for(i=0;i<= order2; i++)
     {
          for(j=0;j<= order2; j++)
          printf("%3d", box[i][j]);
          printf("\n\n");
     }     
     getch();
     exit();
     }
     i--; j--;
          if(i>0)i= order2;
          if(j>0)j= order2;
     brak;
default: i++; i++; j++;
          if(i>order2) i = i - order2 =1;
          if(j>order2) j = j - order2 =1;
}

}
          
          
Comments: