Go4Expert

Go4Expert (http://www.go4expert.com/)
-   C (http://www.go4expert.com/forums/c/)
-   -   Cropping a 2d array (http://www.go4expert.com/forums/cropping-2d-array-t10792/)

thamiz 25May2008 07:35

Cropping a 2d array
 
Hi there;
i am new to c prograaming;
i was wondering if there is any way in c to crop a 2d array.
for example
say i have the 2d array below;
int array[15][15]={{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
{0,0,0,0,1,1,1,1,1,1,1,0,0,0,0},
{0,0,0,1,0,0,0,0,0,0,0,1,0,0,0},
{0,0,0,1,0,0,0,0,0,0,0,1,0,0,0},
{0,0,0,1,0,0,0,0,0,0,0,1,0,0,0},
{0,0,0,1,0,0,0,0,0,0,0,1,0,0,0},
{0,0,0,1,1,1,1,1,1,1,1,1,0,0,0},
{0,0,0,1,0,0,0,0,0,0,0,1,0,0,0},
{0,0,0,1,0,0,0,0,0,0,0,1,0,0,0},
{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}};
the computer will create a new array;
and just print out this portion of the array;
{0,0,0,0,1,1,1,1,1,1,1,0,0,0,0},
{0,0,0,1,0,0,0,0,0,0,0,1,0,0,0},
{0,0,0,1,0,0,0,0,0,0,0,1,0,0,0},
{0,0,0,1,0,0,0,0,0,0,0,1,0,0,0},
{0,0,0,1,0,0,0,0,0,0,0,1,0,0,0},
{0,0,0,1,1,1,1,1,1,1,1,1,0,0,0},
{0,0,0,1,0,0,0,0,0,0,0,1,0,0,0},
{0,0,0,1,0,0,0,0,0,0,0,1,0,0,0}}
ie if all the cols in a row contain 0; it should not copy the row into the new 2d array..
cheers.
thank in advance for any one that can help me..


All times are GMT +5.5. The time now is 07:13.