Hello everybody.
Basically, what I want to know is, how would shell shorting method work in such program , cause I don't clearly understand the algorithm of this method..
The program:
#pragma argsused
#include <conio.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int i,j; //cikla mainigie
int *p; //norade uz masivu ar noradem
int n; //masiva elementu daudzuma mainigais
int temp; //temp mainigais, hvz?
int *garumi; //dinamiska masivo kolonnu,rindu skaita daudzuma masivs
int **matrica; //dinamiskais masivs
int main(){
n=-10;
while (n<0)
{
printf("How much rows??\n");
scanf("\n%d", &n);
if (n<0)
{
printf("The amount of rows must be > 0!");
getch();
clrscr();
}
}
garumi=(int*)calloc(n,sizeof(int));
matrica=(int**)calloc(n,sizeof(int*));
for (i=0;i<n;i++)
{
printf ("How much columns will %d. row have?\n", i+1);
scanf ("%d",&garumi[i]);
while (garumi[i]<0)
{
if (garumi[i]<0)
{
printf ("number of columns must be > 0!");
getch();
clrscr();
}
printf ("How much rows in %d. row??\n", i+1);
scanf ("%d",&garumi[i]);
}
for (j=0;j<garumi[i];j++)
{
printf("Enter [%d][%d] element: ", i+1,j+1);
scanf("%d",&garumi[i]);
}
}
getch();
}
and now I should sort it, but I don't know how to do it, if anyone can help me, thanks :)
I would also like to know how can I change the amount of columns in a row? like add/delete function? I'm so confused about all this.