Newer
Older
#include "triInsertion.h"
#include "triFusion.h"
#include "triRapide.h"
if((strcmp(argv[1], "--insertion") == 0) || strcmp(argv[1], "-i")== 0){
int n = readToTab(tab, argv[2]);
printf("Base : ");
for(int i = 0; i<n; i++){
printf("%ld,", tab[i]);
}
printf("\n");
triInsertion(tab, n);
printf("Insertion : ");
for(int i = 0; i<n; i++){
printf("%ld,", tab[i]);
}
printf("\n");
else if(strcmp(argv[1], "--fusion")== 0 || strcmp(argv[1], "-f")== 0){
int n = readToTab(tab, argv[2]);
printf("Base : ");
for(int i = 0; i<n; i++){
printf("%ld,", tab[i]);
}
printf("\n");
for(int i = 0; i<n; i++){
printf("%ld,", tab[i]);
}
printf("\n");
else if((strcmp(argv[1], "--rapide")== 0) || strcmp(argv[1], "-r")== 0){
int n = readToTab(tab, argv[2]);
printf("Base : ");
for(int i = 0; i<n; i++){
printf("%ld,", tab[i]);
}
printf("\n");
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)
{
int n = readToTab(tab, argv[2]);
printf("Base : ");
for(int i = 0; i<n; i++){
printf("%ld,", tab[i]);
}
printf("\n");
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");
for(int i = 0; i<n; i++){
printf("%ld,", tab[i]);
}
printf("\n");
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
else if (strcmp(argv[1], "-g") == 0)
{
if(argc<3){
printf("Usage: ./tri -g <output.txt> <size>\n");
exit(1);
}
long *tab;
size_t t = 0;
if(argc==3){
t = NULL;
}
else{
t = atoi(argv[3]);
}
size_t l = 0;
int fd = open(argv[2], O_RDWR | O_CREAT);
tab = generate_tab(t, &l);
dup2(fd, 1);
for(int i = 0; i<t; i++){
printf("%ld ", tab[i]);
}
printf(".");
printf("\n");
close(fd);
// free(tab);
}