50 lines
1.2 KiB
C
50 lines
1.2 KiB
C
#include "IdanLib.h"
|
|
#include <stdio.h>
|
|
|
|
#define N 7
|
|
#define N2 6
|
|
#define REMOVE_COL 3
|
|
#define REMOVE_ROW 5
|
|
|
|
void OutputPrintMatrix(int mat[][N2], unsigned int row_size, unsigned int column_size)
|
|
{
|
|
unsigned int counter_row,
|
|
counter_col;
|
|
for (counter_row = ZERO; counter_row < row_size; counter_row++)
|
|
{
|
|
for (counter_col = ZERO; counter_col < column_size; counter_col++)
|
|
{
|
|
printf("%d ", mat[counter_row][counter_col]);
|
|
}
|
|
printf("\n");
|
|
}
|
|
}
|
|
|
|
|
|
void main(void)
|
|
{
|
|
int mat1[N][N] = { ZERO };
|
|
int mat2[N2][N2] = { ZERO };
|
|
int row1, col1, row2, col2;
|
|
|
|
for (unsigned short i = 0; i < N * N; i++)
|
|
{
|
|
mat1[i / N][i % N] = i+1;
|
|
}
|
|
|
|
|
|
for (unsigned counter = (REMOVE_ROW * (N2) + REMOVE_COL); counter < (N2 * N2) + (REMOVE_ROW * (N2) + REMOVE_COL) ; counter++)
|
|
{
|
|
row2 = ((counter - REMOVE_COL)/ N2) % N2;
|
|
col2 = (counter % N2);
|
|
row1 = (((counter - REMOVE_COL) / N2) + ((N - N2) * ((counter / N2) >= REMOVE_ROW))) % N;
|
|
col1 = ((counter % N2) + ((N - N2) * ((counter % N2) >= REMOVE_COL))) % N;
|
|
mat2[row2][col2] = mat1[row1][col1];
|
|
}
|
|
|
|
|
|
printf("\n\n");
|
|
OutputPrintMatrix(mat2, N2, N2);
|
|
|
|
|
|
} |