Originally posted by maxima
hi souldog,
your given function is interesting. but it is not giving me the correct result.
i wrote a small code for this.......
Code:
#include<stdio.h>
int main()
{
int my_vector[65];//buffer
int my_matrix[8][8] = { { 0,1,5,6,14,15, 27, 28 },
{ 2,4,7,13,16,26,29,42},
{ 3,8,12,17,25,30,41,43},
{ 9,11,18,24,31,40,44,53},
{ 10,19,23,32,39,45,52,54},
{ 20,22,33,38,46,51,55,60},
{ 21,34,37,47,50,56,59,61},
{ 35,36,48,49,57,58,62,63}
};
for(int m=0;m<8;m++) //CHANGE UPPER LIMIT TO EIGHT
for(int n =0;n<8;n++) //CHANGE UPPER LIMIT TO EIGHT
{
int j = (7 >= m+n ? 0 : (m+n - 7));
for(int i = 1; i < (7 >= m+n ? 0 : (m+n - 7)); i++)
j += 2*i ;
my_vector[((m+n)*(m+n)+3*m+n)/(2) - j] = my_matrix[m][n];
}
for(m=0;m<64;m++) printf("%d\n",my_vector[m]);
return 0;
}
if i read from my_matrix[][] in a zigzag way then my_vector should print 1,2,3,4,5...........,63 is not it??? but its not giving that result...... some where there is mistake. its not reading in a zigzag way???????????
To nsh123
-----------------------
although i could not understand what exactly you wanted to mean by your example .......but i guess you want to creat a matrix(index matrix??) whose elements are the number in which way they are being acessed....so basically there would be a 8x8 index matrix
i have to define at the beginig of the code.
plz can you explain more by a small code??
thanks