Skip to content
Snippets Groups Projects
Commit 02488b6f authored by SCHMIDT LUCAS's avatar SCHMIDT LUCAS
Browse files

Ajout de la structure compte et fonctions de comptage

parent 806ffea7
No related merge requests found
#include <stdio.h>
#include <stdlib.h>
void copierTableau(long* dest,long* src,size_t n){
for(size_t i = 0;i < n;i++){
dest[i] = src[i];
}
}
#include "utils.h"
void fusion(long* A,size_t p,size_t q,size_t r){
size_t n1 = q-p;
......@@ -50,17 +46,6 @@ void triFusion(long* A,size_t n){
sousTriFusion(A,0,n);
}
void printTab(long* A,size_t n){
printf("{");
for(size_t i = 0;i < n;i++){
if(i != 0){
printf(",");
}
printf("%ld",A[i]);
}
printf("}\n");
}
int main(int argc,char** argv){
long* A = malloc((argc-1)*sizeof(long));
for(size_t i = 0;i < argc-1;i++){
......
#include <stdio.h>
#include <stdlib.h>
#include "utils.h"
void triInsertion(long* A, size_t n){
for(size_t i = 1; i < n; i ++){
long cle = A[i];
......@@ -13,17 +15,6 @@ void triInsertion(long* A, size_t n){
}
}
void printTab(long* A,size_t n){
printf("{");
for(size_t i = 0;i < n;i++){
if(i != 0){
printf(",");
}
printf("%ld",A[i]);
}
printf("}\n");
}
int main(int argc, char* argv[]){
long* A = malloc((argc-1)*sizeof(long));
for(size_t i = 0;i < argc-1;i++){
......
#include <stdio.h>
#include <stdlib.h>
void permuter(long* a,long* b){
long tmp = *a;
*a = *b;
*b = tmp;
}
#include "utils.h"
size_t partition(long* A,size_t p,size_t r){
long pivot = A[r-1];
......@@ -32,17 +28,6 @@ void triRapide(long* A,size_t n){
sousTriRapide(A,0,n);
}
void printTab(long* A,size_t n){
printf("{");
for(size_t i = 0;i < n;i++){
if(i != 0){
printf(",");
}
printf("%ld",A[i]);
}
printf("}\n");
}
int main(int argc,char** argv){
long* A = malloc((argc-1)*sizeof(long));
for(size_t i = 0;i < argc-1;i++){
......
......@@ -10,6 +10,7 @@ void printTab(long* A,size_t n){
printf("{");
for(size_t i = 0;i < n;i++){
if(i != 0){
printf(",");
}
printf("%ld",A[i]);
......@@ -22,3 +23,29 @@ void permuter(long* a,long* b){
*a = *b;
*b = tmp;
}
void initCompte(struct compte* c){
c->comp = 0;
c->ecrit = 0;
}
char comparer(long a,char* op,long b,struct compte* c){
c->comp++;
if(!strcmp(op,"==")){
return (a == b);
}else if(!strcmp(op,"<")){
return (a < b);
}else if(!strcmp(op,">")){
return (a > b);
}else if(!strcmp(op,"<=")){
return (a <= b);
}else if(!strcmp(op,">=")){
return (a >= b);
}
return 0;
}
void ecriture(long* a,long b,struct compte* c){
c->ecrit++;
*a = b;
}
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
struct compte{
size_t comp;
size_t ecrit;
}
void copierTableau(long* dest,long* src,size_t n);
void printTab(long* A,size_t n);
void permuter(long* a,long* b);
void initCompte(struct compte* c);
char comparer(long a,char* op,long b,struct compte* c);
void ecrire(long* a,long b,struct compte* c);
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