a
This commit is contained in:
BIN
APL1.2/1.Allocation_dynamique/source/Palindrome
Normal file
BIN
APL1.2/1.Allocation_dynamique/source/Palindrome
Normal file
Binary file not shown.
37
APL1.2/1.Allocation_dynamique/source/Palindrome.c
Normal file
37
APL1.2/1.Allocation_dynamique/source/Palindrome.c
Normal file
@@ -0,0 +1,37 @@
|
||||
#include<stdio.h>
|
||||
#include<stdlib.h>
|
||||
#include<string.h>
|
||||
|
||||
void inverse(const char* s);
|
||||
|
||||
|
||||
int main(int argc,char* argv[]){
|
||||
|
||||
inverse(argv[1]);
|
||||
|
||||
printf("on fini\n");
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void inverse(const char* s){
|
||||
|
||||
|
||||
char *reverseString=NULL;
|
||||
int compteur=0, longueurString= strlen(s);
|
||||
|
||||
|
||||
reverseString=malloc( ( longueurString+1 ) *sizeof(char) );
|
||||
|
||||
for(compteur=longueurString;compteur>0;compteur--){
|
||||
|
||||
reverseString[longueurString-compteur]=s[compteur];
|
||||
}
|
||||
|
||||
reverseString[longueurString+1]='\0';
|
||||
|
||||
printf("La chaine de base est %s\n",s);
|
||||
printf("la chaine truc est %s\n",reverseString );
|
||||
}
|
||||
140
APL1.2/1.Allocation_dynamique/source/Singleton.c
Normal file
140
APL1.2/1.Allocation_dynamique/source/Singleton.c
Normal file
@@ -0,0 +1,140 @@
|
||||
#include<stdio.h>
|
||||
#include<stdlib.h>
|
||||
|
||||
|
||||
/*---------------------PROTOTYPE---------------------------------------------*/
|
||||
|
||||
|
||||
|
||||
int nombreSingletonTableau(double tableau[], int tailleTableau);
|
||||
|
||||
void valeurSingleton(double tableau[], double tableauFinal[], int tailleTableau, int tailleTableauFinal);
|
||||
|
||||
void afficheTableau(double tableau[], int tailleTableau);
|
||||
|
||||
|
||||
|
||||
/*-------------------------------MAIN----------------------------------------------------*/
|
||||
|
||||
int main(void){
|
||||
|
||||
double *tableau=NULL, *tableauFinal=NULL;
|
||||
int compteur=0, reponse=0, compteurBis=0, tailleTableauFinal;
|
||||
|
||||
printf("Veuillez entrez le nombre de réel que vous allez entrez : ");
|
||||
scanf("%d", &reponse);
|
||||
|
||||
|
||||
tableau=(double*) malloc(reponse*sizeof(double));
|
||||
|
||||
|
||||
for(compteur=0;compteur<reponse;compteur++){
|
||||
|
||||
|
||||
printf("Veuillez entrez le reel %d/%d\n",compteur+1, reponse);
|
||||
|
||||
scanf("%lf", &tableau[compteur]);
|
||||
|
||||
}
|
||||
|
||||
tailleTableauFinal = nombreSingletonTableau(tableau,reponse);
|
||||
|
||||
printf("Il y'a %d Singleton\n\nCes derniers sont : \n\n",tailleTableauFinal);
|
||||
|
||||
|
||||
tableauFinal=malloc(tailleTableauFinal*sizeof(double));
|
||||
|
||||
|
||||
valeurSingleton(tableau, tableauFinal, reponse, tailleTableauFinal);
|
||||
|
||||
afficheTableau(tableauFinal, tailleTableauFinal);
|
||||
|
||||
|
||||
free(tableau);
|
||||
free(tableauFinal);
|
||||
|
||||
printf("\nAu revoir\n");
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/*---------------------------------------------------FONCTIONS---------------------------------------------------------------------*/
|
||||
|
||||
int nombreSingletonTableau(double tableau[], int tailleTableau){
|
||||
|
||||
int compteur=0, compteurBis=0, compteurCase=0 , nombreSingleton=0;
|
||||
|
||||
|
||||
for(compteur=0;compteur<tailleTableau;compteur++){
|
||||
|
||||
compteurCase=1; /*1 represente la case en question elle meme */
|
||||
|
||||
|
||||
|
||||
for(compteurBis=0;compteurBis<tailleTableau;compteurBis++){
|
||||
|
||||
if(tableau[compteur]!=tableau[compteurBis] && compteur!=compteurBis){
|
||||
|
||||
compteurCase++;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if(compteurCase == tailleTableau){
|
||||
|
||||
nombreSingleton++;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
return nombreSingleton;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void valeurSingleton(double tableau[], double tableauFinal[], int tailleTableau, int tailleTableauFinal ){
|
||||
|
||||
int compteur=0, compteurBis=0, compteurCase=0 , caseTableauFinal=0;
|
||||
|
||||
|
||||
for(compteur=0;compteur<tailleTableau;compteur++){
|
||||
|
||||
compteurCase=1; /*1 represente la case en question elle meme */
|
||||
|
||||
|
||||
|
||||
for(compteurBis=0;compteurBis<tailleTableau;compteurBis++){
|
||||
|
||||
if(tableau[compteur]!=tableau[compteurBis] && compteur!=compteurBis){
|
||||
|
||||
compteurCase++;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if(compteurCase == tailleTableau){
|
||||
|
||||
tableauFinal[caseTableauFinal++]=tableau[compteur];
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void afficheTableau(double tableau[], int tailleTableau){
|
||||
|
||||
int compteur=0;
|
||||
|
||||
for(compteur=0;compteur<tailleTableau;compteur++){
|
||||
|
||||
printf("%lf ", tableau[compteur]);
|
||||
}
|
||||
printf("\n");
|
||||
|
||||
}
|
||||
|
||||
113
APL1.2/1.Allocation_dynamique/source/Singletons.c
Normal file
113
APL1.2/1.Allocation_dynamique/source/Singletons.c
Normal file
@@ -0,0 +1,113 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
|
||||
|
||||
//_____________________PROTOTYPE_____________________________
|
||||
|
||||
|
||||
int parcourTableau(int tableau[], int tailleTableau);
|
||||
void singletonTableau(int tableau[], int tableauFinale[], int tailleTableau);
|
||||
|
||||
|
||||
int main(void){
|
||||
|
||||
int reponse=0, compteur=0;
|
||||
int *tableau;
|
||||
|
||||
|
||||
printf("Combien de valeurs voulez vous rentrez ?\nNombre de valeurs: ");
|
||||
scanf("%d", &reponse);
|
||||
|
||||
malloc(reponse*sizeof(int));
|
||||
|
||||
for(compteur=0;compteur<reponse;compteur++){
|
||||
|
||||
printf("Votre entier : ");
|
||||
scanf(" %d", tableau[compteur]);
|
||||
}
|
||||
|
||||
|
||||
|
||||
printf("La saisie des entier est finie, voici les reel que vous n'avez entrez qu'une seule fois : \n ");
|
||||
|
||||
if(NombreSingletonTableau(tableau[], reponse)==0){
|
||||
|
||||
printf("Il n'ya pas de singletons\n");
|
||||
return EXIT_FAILURE
|
||||
|
||||
} else {
|
||||
int *tableauFinal;
|
||||
tableauFinal=malloc(NombreSingletonTableau(tableau[], reponse)*sizeof(int));
|
||||
|
||||
singletonTableau(tableau,tableauFinal,reponse,NombreSingletonTableau(tableau[],reponse));
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
free(tableau);
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
//___________________________FONCTIONS___________________________________
|
||||
|
||||
int NombreSingletonTableau(int tableau[], int tailleTableau){
|
||||
|
||||
|
||||
int compteur=0, nombreSingleton = 0;
|
||||
int compteurBis=0;
|
||||
|
||||
for(compteur=0;compteur<tailleTableau;compteur++){
|
||||
|
||||
for(compteurBis=0;compteurBis<tailleTableau;compteur++){
|
||||
|
||||
if(tableau[compteur]==tableau[compteurBis]){
|
||||
nombreSingleton++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return nombreSingleton;
|
||||
|
||||
|
||||
}
|
||||
|
||||
void singletonTableau(int tableau[], int tableauFinale[], int tailleTableau){
|
||||
|
||||
int compteur=0;
|
||||
int compteurBis=0;
|
||||
|
||||
for(compteur=0;compteur<tailleTableau;compteur++){
|
||||
|
||||
for(compteurBis=0;compteurBis<tailleTableau;compteur++){
|
||||
|
||||
if(tableau[compteur]==tableau[compteurBis]){
|
||||
|
||||
tableauFinale[compteur]=tableau[compteur];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user