#include <stdio.h>
#define DELETED_ROW 0
#define DELETED_COLUMN 0
int main(int argc, char *argv[])
{
int A[3][3], B[2][2];
int i, j;
for (i = 0; i < 3; i++)
for (j = 0; j < 3; j++)
A[i][j] = i * 3 + j + 1;
for (i = 0; i < 3; i++)
{
printf("\n");
for (j = 0; j < 3; j++)
printf("A[%d][%d]=%d\t", i, j, A[i][j]);
}
for (i = 0; i < 3; i++)
if (i != DELETED_ROW)
{
for (j = 0; j < 3; j++)
if (j != DELETED_COLUMN)
{
if (i < DELETED_ROW && j < DELETED_COLUMN)
B[i][j] = A[i][j];
else if (i < DELETED_ROW && j > DELETED_COLUMN)
B[i][j-1] = A[i][j];
else if (i > DELETED_ROW && j < DELETED_COLUMN)
B[i-1][j]=A[i][j];
else
B[i-1][j-1]=A[i][j];
}
}
for (i = 0; i < 2; i++)
{
printf("\n");
for (j = 0; j < 2; j++)
printf("B[%d][%d]=%d\t", i, j, B[i][j]);
}
return 0;
}
Comments
Leave a comment