Skip to content
Snippets Groups Projects
Commit 2601114b authored by chafiol's avatar chafiol
Browse files

1er rendu sans readme

parent 05f56597
Branches
No related merge requests found
No preview for this file type
......@@ -3,8 +3,7 @@
void triInsertion(long* A, size_t n){
long cle = 0;
size_t max = 0;
max--;
size_t max = 0; max--;
for(size_t i = 1; i<n; i++){
cle=A[i];
size_t j = i - 1;
......@@ -75,33 +74,30 @@ void triFusion(long * A, size_t n){
}
void sousTriRapide(long* A, size_t p, size_t r) {
if (p<(r-1)) {
size_t q = partition(A, p, r);
sousTriRapide(A, p, q);
sousTriRapide(A, q+1, r);
size_t max = 0; max--;
if(r-1 != max){
if (p<(r-1)) {
size_t q = partition(A, p, r);
sousTriRapide(A, p, q);
sousTriRapide(A, q+1, r);
}
}
}
size_t partition(long* A, size_t p, size_t r) {
printf("r >>>>>>>>>> %d\n", r);
size_t max = 0;
max--;
size_t pivot = 0;
if(r-1 != max){
pivot = A[r-1];
}
long pivot = A[r-1];
size_t i = p;
long temp;
for (size_t j = p; j < r-2; j++) {
for (size_t j = p; j <= r-2; j++) {
if (A[j] <= pivot) {
temp = A[i];
long temp = A[i];
A[i] = A[j];
A[j] = temp;
i++;
}
}
temp = A[i];
long temp = A[i];
A[i] = A[r-1];
A[r-1] = temp;
return i;
......
No preview for this file type
......@@ -17,7 +17,7 @@ int readToTab(long* tab, char* file){
if(temp != ' '){
tmp[x] = temp;
x++;
n++;
}
else if(temp == ' '){
long t = atol(tmp);
......@@ -25,6 +25,7 @@ int readToTab(long* tab, char* file){
memset(tmp, 0, 1000);
j++;
x=0;
n++;
}
read(fd,&temp,sizeof(char));
}
......@@ -44,7 +45,7 @@ int main(int argc, char **argv){
}
printf("\n");
if((strcmp(argv[1], "--insertion") == 0)){
if((strcmp(argv[1], "--insertion") == 0) || strcmp(argv[1], "-i")== 0){
triInsertion(tab, n);
printf("Insertion : ");
for(int i = 0; i<n; i++){
......@@ -52,7 +53,7 @@ int main(int argc, char **argv){
}
printf("\n");
}
else if((strcmp(argv[1], "--fusion")== 0)){
else if(strcmp(argv[1], "--fusion")== 0 || strcmp(argv[1], "-f")== 0){
triFusion(tab, n);
printf("Fusion : ");
for(int i = 0; i<n; i++){
......@@ -60,9 +61,30 @@ int main(int argc, char **argv){
}
printf("\n");
}
else if((strcmp(argv[1], "--rapide")== 0)){
else if((strcmp(argv[1], "--rapide")== 0) || strcmp(argv[1], "-r")== 0){
triRapide(tab, n);
printf("Rapide : ");
for(int i = 0; i<n; i++){
printf("%ld,", tab[i]);
}
printf("\n");
}
else if (strcmp(argv[1], "-a") == 0)
{
triInsertion(tab, n);
printf("Insertion : ");
for(int i = 0; i<n; i++){
printf("%ld,", tab[i]);
}
printf("\n");
triFusion(tab, n);
printf("Fusion : ");
for(int i = 0; i<n; i++){
printf("%ld,", tab[i]);
}
printf("\n");
triRapide(tab, n);
printf("Rapide : ");
printf("Rapide : ");
for(int i = 0; i<n; i++){
printf("%ld,", tab[i]);
}
......
all: algo
all: tri
algo: main.c algos.o
gcc -Wall main.c algos.o -Wall
tri: main.c algos.o
gcc -Wall main.c algos.o -Wall -o tri
algos: algos.c algos.h
gcc -c algos.c algos.h -Wall
......
40 47 12 2 25 3 14 65 48 10 1 56 94 45 36 27 6 7 19 16 24 38 37 11 78 5 18 54 20 21 82 42 32 22 19 9 53 41 99 125 111 248 33 .
\ No newline at end of file
40 47 12 2 25 3 14 65 48 10 1 56 94 45 36 27 6 7 19 16 24 38 37 11 .
\ No newline at end of file
File moved
File added
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment