online compiler and debugger for c/c++

code. compile. run. debug. share.
Source Code    Language
/****************************************************************************** Online C++ Compiler. Code, Compile, Run and Debug C++ program online. Write your code in this editor and press "Run" button to compile and execute it. *******************************************************************************/ #include <stdio.h> #include <stdlib.h> #include <time.h> // Dobrze**************************************** typedef struct table { int size; int *ptr; } tab; void wprowadz_dlugosc1 (tab * tab1); void sprawdz_dlugosc1 (tab * tab1); void malloc_tab (tab * tab1); void insertion_sort1 (tab * tab1); void insertion_sort2 (tab * tab1); void losuj_liczby1 (tab * tab1); void wyswietl_tab1 (tab * tab1); //**************************************** int dlugosc_tab; void wprowadz_dlugosc (int *tab1); void sprawdz_dlugosc (int *tab1); void insertion_sort (int *tab1); void losuj_liczby (int *tab1); void wyswietl_tab (int *tab1); ///////////////////////////////////////////////////// void swap (int *a, int *b); ///main////////////////////////////////////////////////// int main () { srand (time (NULL)); // Dobrze **************************************** tab *t1; sprawdz_dlugosc1 (t1); malloc_tab (t1); losuj_liczby1 (t1); insertion_sort1 (t1); wyswietl_tab1 (t1); free (t1->ptr); //**************************************** sprawdz_dlugosc (&dlugosc_tab); printf ("\n dlugosc :%d\n", dlugosc_tab); int *tab1 = malloc (sizeof *tab1 * (dlugosc_tab + 1)); if (!tab1) { perror ("malloc"); return -1; } losuj_liczby (tab1); insertion_sort (tab1); wyswietl_tab (tab1); free (tab1); } ///end main////////////////////////////////////////////////// // Dobrze **************************************** void wprowadz_dlugosc1 (tab * tab1) { printf ("\nPodaj dlugosc :"); scanf ("%d", &(tab1->size)); return; } void sprawdz_dlugosc1 (tab * tab1) { while (tab1->size < 8 || tab1->size > 22) { printf ("\nDlugosc tablicy [8-22] elementow."); wprowadz_dlugosc1 (tab1); } return; } void malloc_tab (tab * tab1) { tab1->ptr = NULL; tab1->ptr = malloc (sizeof (*(tab1->ptr)) * (tab1->size + 1)); if (tab1->ptr == NULL) { perror ("malloc"); exit (-1); } return; } void losuj_liczby1 (tab * tab1) { int i; for (i = 0; i < tab1->size; i++) tab1->ptr[i] = -5 + rand () % 11; return; } void wyswietl_tab1 (tab * tab1) { int i; for (i = 0; i < tab1->size; i++) printf (" %d,", tab1->ptr[i]); return; } void insertion_sort1 (tab * tab1) { int i, j; if (tab1->size < 2) return; for (i = 1; i < tab1->size; i++) { j = i; while (j > 0 && tab1->ptr[j] < tab1->ptr[j - 1]) { swap (&tab1->ptr[j], &tab1->ptr[j--]); } } return; } //**************************************** ////////////////////////////////////////////////////////// void wprowadz_dlugosc (int *tab1) { printf ("\nPodaj dlugosc :"); scanf ("%d", &(*tab1)); return; } void sprawdz_dlugosc (int *tab1) { while (*tab1 < 8 || *tab1 > 22) { printf ("\nDlugosc tablicy [8-22] elementow."); wprowadz_dlugosc (&*tab1); } return; } void losuj_liczby (int *tab1) { int i; for (i = 0; i < dlugosc_tab; i++) tab1[i] = -5 + rand () % 11; return; } void wyswietl_tab (int *tab1) { int i; for (i = 0; i < dlugosc_tab; i++) printf (" %d,", tab1[i]); return; } void insertion_sort (int *tab1) { int i, j; if (dlugosc_tab < 2) return; for (i = 1; i < dlugosc_tab; i++) { j = i; while (j > 0 && tab1[j] < tab1[j - 1]) { swap (&tab1[j], &tab1[j--]); } } return; } ////////////////////////////////////////////////////////// void swap (int *a, int *b) { *a = *b + *a; *b = *a - *b; *a = *a - *b; }

Compiling Program...

Command line arguments:
Standard Input: Interactive Console Text
×

                

                

Program is not being debugged. Click "Debug" button to start program in debug mode.

#FunctionFile:Line
VariableValue
RegisterValue
ExpressionValue