This commit is contained in:
Maryna Kravtsova 2020-11-30 12:49:20 +01:00
parent d0d15dad61
commit c90ba22b74

View File

@ -5,7 +5,7 @@
#include <ctype.h>
#include <stdbool.h>
void check_heap(int size, int* array){
void check_heap(int size, long int* array){
int i;
for(i = 0; i < size; i++){
int c = (2 * i) + 1;
@ -37,12 +37,12 @@ void space(int l){
}
void print(int *arr, int i, int size, int c, int level){
void print(long int *arr, int i, int size, int c, int level){
if(i >= size){
return;
}
space(level);
printf("%d\n", arr[i]);
printf("%ld\n", arr[i]);
print(arr,i*2+1, size, c, level+1);
print(arr, i*2+2, size, c, level+1);
@ -50,11 +50,18 @@ void print(int *arr, int i, int size, int c, int level){
int main() {
char* cisla = calloc(100, sizeof(char));
char cisla[100];
char *r = fgets(cisla, 100, stdin);
if(r == NULL){
return 0;
}
cisla[strlen(cisla)-1] = '\0';
int size = strlen(cisla);
long int num[size];
fgets(cisla, 100, stdin);
int size = cisla[strlen(cisla)-1];
int* num = calloc(size, sizeof(int));
char *end;
int i = 0;
while(i != size){
@ -62,6 +69,7 @@ int main() {
long int c = strtol(cisla, &end, 10);
num[i] = c;
}
else{
long int next = strtol(end, &end, 10);
@ -72,18 +80,17 @@ int main() {
}
i = 0;
int count = 0;
while(num[i] != 0){
while(num[i] != '\0'){
count++;
i++;
i++;
}
i = 0;
int index = 0;
int l = 0;
int k = 36;
check_heap(count, num);
int j = 0;
print(num, index, count,num[0],l);
free(cisla);
free(num);
return 0;
}