prvy
This commit is contained in:
parent
6a26a4026d
commit
4c1881da8c
@ -10,13 +10,13 @@ return 1;
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int backtracking(char* maze, int x, int y, int size){
|
int backtracking(char* maze, int x, int y, int size){ //https://www.geeksforgeeks.org/rat-in-a-maze-backtracking-2/
|
||||||
if(x == size - 1 && y == size - 1 && maze[x * size + y] == ' '){
|
if(x == size - 1 && y == size - 1 && maze[x * size + y] == ' '){ //kontrola ci sa nachadzam na konci
|
||||||
maze[x * size + y] = '*';
|
maze[x * size + y] = '*';
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(issafe(maze, x, y, size) == 1) {
|
if(issafe(maze, x, y, size) == 1) { // znazornenie stien
|
||||||
maze[x * size + y] = '*';
|
maze[x * size + y] = '*';
|
||||||
|
|
||||||
if (backtracking(maze, x, y + 1, size) == 1) {
|
if (backtracking(maze, x, y + 1, size) == 1) {
|
||||||
|
@ -24,7 +24,7 @@ void delete(struct dict* tree){
|
|||||||
for (int i = 0 ;i < SIZE; i++){
|
for (int i = 0 ;i < SIZE; i++){
|
||||||
delete(tree-> characters[i]);
|
delete(tree-> characters[i]);
|
||||||
}
|
}
|
||||||
free(tree);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void get_words (struct dict* tree,char* words[]){
|
void get_words (struct dict* tree,char* words[]){
|
||||||
@ -102,7 +102,7 @@ int mylz78compress(char* buff,int size,char** outbuf){
|
|||||||
}
|
}
|
||||||
|
|
||||||
delete(root);
|
delete(root);
|
||||||
free(words);
|
|
||||||
|
|
||||||
*outbuf = temp;
|
*outbuf = temp;
|
||||||
return strlen(temp);
|
return strlen(temp);
|
||||||
@ -183,9 +183,7 @@ void compress(FILE* infile,FILE* outfile){
|
|||||||
fwrite(outbuf,sizeof(char),outsize,outfile);
|
fwrite(outbuf,sizeof(char),outsize,outfile);
|
||||||
}
|
}
|
||||||
|
|
||||||
free(buffer);
|
|
||||||
free(tempbuf);
|
|
||||||
free(outbuf);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -204,7 +202,6 @@ int myrldecompress(char* buff,int size,char** outbuf){
|
|||||||
char *tempbuf = calloc(size,sizeof(char));
|
char *tempbuf = calloc(size,sizeof(char));
|
||||||
memset(tempbuf,'\0',size);
|
memset(tempbuf,'\0',size);
|
||||||
strcpy(tempbuf,*outbuf);
|
strcpy(tempbuf,*outbuf);
|
||||||
free(*outbuf);
|
|
||||||
*outbuf = tempbuf;
|
*outbuf = tempbuf;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -242,7 +239,6 @@ int mylz78decompress(char* buff,int size,char** outbuf){
|
|||||||
char *tempbuf = calloc(size,sizeof(char));
|
char *tempbuf = calloc(size,sizeof(char));
|
||||||
memset(tempbuf,'\0',size);
|
memset(tempbuf,'\0',size);
|
||||||
strcpy(tempbuf,*outbuf);
|
strcpy(tempbuf,*outbuf);
|
||||||
free(*outbuf);
|
|
||||||
*outbuf = tempbuf;
|
*outbuf = tempbuf;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -278,8 +274,5 @@ void decompress(FILE* infile,FILE* outfile){
|
|||||||
fwrite(outbuf,sizeof(char),outsize,outfile);
|
fwrite(outbuf,sizeof(char),outsize,outfile);
|
||||||
}
|
}
|
||||||
|
|
||||||
free(buffer);
|
|
||||||
free(tempbuf);
|
|
||||||
free(outbuf);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
BIN
sk2a/program
BIN
sk2a/program
Binary file not shown.
@ -24,7 +24,6 @@ return;
|
|||||||
for (int i = 0 ;i < SIZE; i++){
|
for (int i = 0 ;i < SIZE; i++){
|
||||||
delete(tree-> characters[i]);
|
delete(tree-> characters[i]);
|
||||||
}
|
}
|
||||||
free(tree);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void get_words (struct dict* tree,char* words[]){ //posielam cely strom a smernik na dvojrozmerne pole
|
void get_words (struct dict* tree,char* words[]){ //posielam cely strom a smernik na dvojrozmerne pole
|
||||||
@ -102,7 +101,7 @@ sprintf(last,"-%d-%c\n",current->index,c); //
|
|||||||
}
|
}
|
||||||
|
|
||||||
delete(root); //nepotrebujeme strom, uvolnime pamat
|
delete(root); //nepotrebujeme strom, uvolnime pamat
|
||||||
free(words);
|
|
||||||
|
|
||||||
*outbuf = temp; //adresa sa zapise do outbuffer
|
*outbuf = temp; //adresa sa zapise do outbuffer
|
||||||
return strlen(temp);
|
return strlen(temp);
|
||||||
@ -183,9 +182,7 @@ char *buffer = calloc(insize,sizeof(char)); //alokuje pamat
|
|||||||
fwrite(outbuf,sizeof(char),outsize,outfile); //napise sa do suboru, z akeho buffera do akeho suboru
|
fwrite(outbuf,sizeof(char),outsize,outfile); //napise sa do suboru, z akeho buffera do akeho suboru
|
||||||
}
|
}
|
||||||
|
|
||||||
free(buffer);
|
|
||||||
free(tempbuf);
|
|
||||||
free(outbuf);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -204,7 +201,6 @@ memset(*outbuf,0,size + 1);
|
|||||||
char *tempbuf = calloc(size,sizeof(char));
|
char *tempbuf = calloc(size,sizeof(char));
|
||||||
memset(tempbuf,'\0',size);
|
memset(tempbuf,'\0',size);
|
||||||
strcpy(tempbuf,*outbuf);
|
strcpy(tempbuf,*outbuf);
|
||||||
free(*outbuf);
|
|
||||||
*outbuf = tempbuf;
|
*outbuf = tempbuf;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -242,7 +238,6 @@ int bytes_read, bytes_read_all = 0; //citame vstupny buffer, necitame p
|
|||||||
char *tempbuf = calloc(size,sizeof(char));
|
char *tempbuf = calloc(size,sizeof(char));
|
||||||
memset(tempbuf,'\0',size);
|
memset(tempbuf,'\0',size);
|
||||||
strcpy(tempbuf,*outbuf);
|
strcpy(tempbuf,*outbuf);
|
||||||
free(*outbuf);
|
|
||||||
*outbuf = tempbuf;
|
*outbuf = tempbuf;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -278,7 +273,4 @@ char *buffer = calloc(insize,sizeof(char));
|
|||||||
fwrite(outbuf,sizeof(char),outsize,outfile);
|
fwrite(outbuf,sizeof(char),outsize,outfile);
|
||||||
}
|
}
|
||||||
|
|
||||||
free(buffer);
|
|
||||||
free(tempbuf);
|
|
||||||
free(outbuf);
|
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user