|
|
@@ -38,15 +38,9 @@ shiftGrid(int** grid, int gridSize, int* gridColSize, int k, int* returnSize,
|
|
|
|
|
|
for ( int i = 0; i < k; ++i ) {
|
|
|
int last = intermed[intermed_size-1];
|
|
|
- int *interinter = calloc(intermed_size, sizeof(int));
|
|
|
- for ( int j = 0; j < intermed_size; ++j ) {
|
|
|
- interinter[j] = intermed[j];
|
|
|
+ for ( int j = intermed_size-1; j > 0; --j ) {
|
|
|
+ intermed[j] = intermed[j-1];
|
|
|
}
|
|
|
- for ( int j = 0; j < intermed_size-1; ++j ) {
|
|
|
- intermed[j+1] = interinter[j];
|
|
|
- }
|
|
|
- //memmove(intermed+1, intermed, intermed_size-2);
|
|
|
- free(interinter);
|
|
|
intermed[0] = last;
|
|
|
}
|
|
|
|
|
|
@@ -122,7 +116,7 @@ r(const struct matrix *m, int k, const struct matrix *exp)
|
|
|
char *m_cstr = matrix_to_cstr(m);
|
|
|
char *ret_cstr = matrix_to_cstr(&ret);
|
|
|
char *exp_cstr = matrix_to_cstr(exp);
|
|
|
- printf("shiftGrid(%s, %d) = %s | exp: %s", m_cstr, k, ret_cstr, exp_cstr);
|
|
|
+ printf("shiftGrid(%s, %d) = %s | exp: %s\n", m_cstr, k, ret_cstr, exp_cstr);
|
|
|
|
|
|
free(m_cstr);
|
|
|
free(ret_cstr);
|