Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <time.h>
- #include <stdio.h>
- #include <stdlib.h>
- #include <stdbool.h>
- #include <stdio_ext.h>
- int **m_realloc(int **m, size_t rows, size_t columns){
- m=realloc(m, rows*sizeof(int*));
- for(size_t y=0; y<rows; y++){
- m[y]=realloc(m[y], columns*sizeof(int));
- }
- return m;
- }
- void m_fill(int **m, size_t rows, size_t columns, size_t or, size_t oc, int max){
- srand((unsigned)time(NULL));
- size_t aux_y=0, aux_x=0;
- if(rows!=or && columns!=oc){
- aux_y=or;
- aux_x=0;
- for(size_t y=aux_y; y<rows; y++){
- for(size_t x=aux_x; x<columns; x++){
- m[y][x]=rand()%max;
- }
- }
- aux_y=0;
- aux_x=oc;
- for(size_t y=aux_y; y<(rows-1); y++){
- for(size_t x=aux_x; x<columns; x++){
- m[y][x]=rand()%max;
- }
- }
- }else{
- if(rows!=or){
- aux_y=or;
- aux_x=0;
- }else{
- aux_y=0;
- aux_x=oc;
- }
- for(size_t y=aux_y; y<rows; y++){
- for(size_t x=aux_x; x<columns; x++){
- m[y][x]=rand()%max;
- }
- }
- }
- }
- void m_show(int **m, size_t rows, size_t columns){
- printf("n");
- for(size_t y=0; y<rows; y++){
- for(size_t x=0; x<columns; x++){
- printf("[%d]t", m[y][x]);
- }
- printf("n");
- }
- printf("n");
- }
- void m_free(int **m, size_t rows){
- for(size_t i=0; i<rows; i++){
- free(m[i]);
- }
- free(m);
- }
- int main(void){
- int max=0;
- size_t or=0, oc=0;
- ssize_t rows=0, columns=0;
- bool decreased=false;
- unsigned char choice='