matrices issue

i have a program that i am doing that i have to confirme some numbers in matrices.

this is my main matrix:
coluna=0;
j=0;
SetConsoleTextAttribute( h , K+142 );
for (int i=1; i<51; i++)
{
  if (n[j]==i)
    {
      SetConsoleTextAttribute( h , K+137 );
      printf( "    X");
      j++;
      SetConsoleTextAttribute( h , K+142 );
    }
  else
   {
     printf( " %4d", i);
   }
coluna ++;
if (coluna == 6)
   {
     printf("\n");
     coluna=0;
   }
}
printf("     ");
printf("\n\n\n");


but now i have to create a matrix that will do first this see if n[j] is equal to m[j] and appear an O in the matrix place...
i allready tryed to do this:
coluna=0;
j=0;
SetConsoleTextAttribute( h , K+142 );
for (int i=1; i<51; i++)
{
  if (m[j]==n[j])
    {
      SetConsoleTextAttribute( h , K+137 );
      printf( "    O");
      j++;
      SetConsoleTextAttribute( h , K+142 );
    }
  else if (n[j]==i)
    {
      SetConsoleTextAttribute( h , K+137 );
      printf( "    X");
      j++;
      SetConsoleTextAttribute( h , K+142 );
    }
  else
   {
     printf( " %4d", i);
   }
coluna ++;
if (coluna == 6)
   {
     printf("\n");
     coluna=0;
   }
}
printf("     ");
printf("\n\n\n");

but it didnt work...it started to give me some big matrix with a lot of O... can someone help me please?
thanks
did you mean to do this??


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
coluna=0;
j=0;
SetConsoleTextAttribute( h , K+142 );
for (int i=1; i<51; i++)
{
  if (m[i]==n[i])     //changed from m[j]==n[i]
    {
      SetConsoleTextAttribute( h , K+137 );
      printf( "    O");
      j++;
      SetConsoleTextAttribute( h , K+142 );
    }
  else if (n[i]==i)               //changed from n[j] == i
    {
      SetConsoleTextAttribute( h , K+137 );
      printf( "    X");
      j++;
      SetConsoleTextAttribute( h , K+142 );
    }
  else
   {
     printf( " %4d", i);
   }
coluna ++;
if (coluna == 6)
   {
     printf("\n");
     coluna=0;
   }
}
printf("     ");
printf("\n\n\n");
no, i forgot to meantion that the n[j] and m[j] are int n[5] and m[5] because i will ask for five numbers that would be the value of those int.

in the way you are meationing would to with all the i's values? because i only want with those especific values
Topic archived. No new replies allowed.