This commit is contained in:
2023-10-23 13:23:36 +02:00
parent 667dae6f1a
commit 322b22f9bf
5711 changed files with 72953 additions and 0 deletions

View File

@@ -0,0 +1,30 @@
#include <stdio.h>
#include <stdlib.h>
int count0(double* tableau, int taille){
int numElement;
int compteurDe0=0;
for (numElement=0; numElement<taille; numElement++){
if ((int) tableau[numElement]==0){
compteurDe0++;
}
}
return compteurDe0;
}
int main(int argc, char** argv){
int numArg;
int nb0;
double* tableau= (double*) malloc((argc-1)*sizeof(double));
for (numArg=0; numArg<argc-1; numArg++){
tableau[numArg]=strtod(argv[numArg+1],NULL);
}
nb0 = count0(tableau,argc-1);
if (nb0 > 1){
printf("%d valeurs nulles\n",nb0);
}
else{
printf("%d valeur nulle\n",nb0);
}
return 0;
}

View File

View File

@@ -0,0 +1,47 @@
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char** argv){
FILE* fichier1;
FILE* fichier2;
char contenu1[2];
char contenu2[2];
size_t resultat1=1;
size_t resultat2=1;
if (argc<=2){
printf("Error: Merci de fournir 2 nom de fichier\n");
return 1;
}
else{
fichier1 = fopen(argv[1], "r");
if (fichier1==NULL){
fprintf(stderr,"Error: impossible d'ouvrir le fichier %s\n",argv[1]);
return 1;
}
else{
fichier2 = fopen(argv[2], "r");
if (fichier2==NULL){
fprintf(stderr,"Error: impossible d'ouvrir le fichier %s\n",argv[2]);
return 1;
}
else{
while (resultat1==1 && resultat2==1){
resultat1 = fread(contenu1, sizeof(char), 1, fichier1);
resultat2 = fread(contenu2, sizeof(char), 1, fichier2);
if (contenu1[0]!=contenu2[0]){
resultat1 = -1;
}
}
if (resultat1 == resultat2){
printf("Fichiers identiques !\n");
}
else{
printf("Fichiers différents !\n");
}
fclose(fichier1);
fclose(fichier2);
return 0;
}
}
}
}

View File

@@ -0,0 +1,47 @@
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char** argv){
FILE* fichier1;
FILE* fichier2;
char contenu1[2];
char contenu2[2];
size_t resultat1=1;
size_t resultat2=1;
if (argc<=2){
printf("Error: Merci de fournir 2 nom de fichier\n");
return 1;
}
else{
fichier1 = fopen(argv[1], "r");
if (fichier1==NULL){
fprintf("Error: impossible d'ouvrir le fichier %s\n",argv[1],stderr);
return 1;
}
else{
fichier2 = fopen(argv[2], "r");
if (fichier2==NULL){
fprintf("Error: impossible d'ouvrir le fichier %s\n",argv[2],stderr);
return 1;
}
else{
while (resultat1==1 && resultat2==1){
resultat1 = fread(contenu1, sizeof(char), 1, fichier1);
resultat2 = fread(contenu2, sizeof(char), 1, fichier2);
if (contenu1[0]!=contenu2[0]){
resultat1 = -1;
}
}
if (resultat1 == resultat2){
printf("Fichiers identiques !\n");
}
else{
printf("Fichiers différents !\n");
}
fclose(fichier1);
fclose(fichier2);
return 0;
}
}
}
}

View File

@@ -0,0 +1,14 @@
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
int main(void){
struct timespec tempsDAttente;
char* message="ERREUR";
int i;
for (i=0; i<6; i++){
tempsDAttente.it_value = tempsDAttente.it_interval+1000000000;
nanosleep(tempsDAttente,NULL);
fprintf(stderr,message[i]);
}
}

View File

View File

@@ -0,0 +1,18 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main(int argc, char** argv){
double uniteDonne = strtod(argv[1],NULL);
double uniteConvertis;
if (argv[2][0]=='i'&&argv[2][1]=='n'&&argv[2][2]=='\0'){
uniteConvertis=uniteDonne*2.54;
printf("%.2lfcm\n",uniteConvertis);
return 0;
}
if (argv[2][0]=='c'&&argv[2][1]=='m'&&argv[2][2]=='\0'){
uniteConvertis=uniteDonne/2.54;
printf("%.2lfin\n",uniteConvertis);
return 0;
}
}

View File

@@ -0,0 +1,14 @@
#include <stdio.h>
#include <stdlib.h>
int main (void){
FILE* fichier = fopen("/dev/random", "r");
unsigned short int resultat;
if (fichier!=NULL){
fread(&resultat,sizeof(unsigned short int),1,fichier);
printf("%hu\n",resultat%6+1);
fclose(fichier);
}else{
fprintf(stderr,"le fichier /dev/random n'a pas réussi à s'ouvrir");
}
}

Binary file not shown.

View File

@@ -0,0 +1,22 @@
#include<stdlib.h>
#include<stdio.h>
int main(void){
int place;
char nom[10][4];
int score[10];
FILE* hallOfFame = fopen("top10","r");
if (hallOfFame){
for (place=0;place<10;place++){
fread(&score[place],sizeof(int),1,hallOfFame);
printf("%09d ",score[place]);
fread(&nom[place],sizeof(char),3,hallOfFame);
nom[place][3]='\0';
printf("%s\n",nom[place]);
}
fclose(hallOfFame);
}
else{
printf("c'est toi qui est null\n");
}
return 0;
}

View File

@@ -0,0 +1,22 @@
#include<stdlib.h>
#include<stdio.h>
int main(void){
int place;
char nom[10][4];
int score[10];
FILE* hallOfFame = fopen("top10","r");
if (hallOfFame){
for (place=0;place<10;place++){
fread(&score[place],sizeof(int),1,hallOfFame);
printf("%09d ",score[place]);
fread(&nom[place],sizeof(char),3,hallOfFame);
nom[place][3]='\0';
printf("%s\n",nom[place]);
}
fclose(hallOfFame);
}
else{
printf("c'est toi qui est null\n");
}
return 0;
}

View File

@@ -0,0 +1,22 @@
#include<stdlib.h>
#include<stdio.h>
int main(void){
int place;
char nom[10][4];
int score[10];
FILE* hallOfFame = fopen("top10","r");
if (hallOfFame){
for (place=0;place<10;place++){
fread(&score[place],sizeof(int),1,hallOfFame);
printf("%09d",score[place]);
fread(&nom[place],sizeof(char),3,hallOfFame);
nom[place][3]='\0';
printf("%4s\n",nom[place]);
}
fclose(hallOfFame);
}
else{
printf("c'est toi qui est null\n");
}
return 0;
}

View File

@@ -0,0 +1,83 @@
#include<stdlib.h>
#include<stdio.h>
#include<string.h>
void inversionInt(int* var1, int* var2){
int valeurTransitoire = *var1;
*var1 = *var2;
*var2 = valeurTransitoire;
}
void inversionMot3(char* var1, char* var2){
char valeurTransitoire;
int pos;
for (pos=0; pos<4; pos++, var1++, var2++){
valeurTransitoire = *var1;
*var1 = *var2;
*var2 = valeurTransitoire;
}
}
void printTop10(int* score, char* challenger){
int place;
for (place=0; place<10; place++, score++, challenger+=4){
printf("%09d",*score);
printf("%4s\n",challenger);
}
printf("\n");
}
int main(int argc, char** argv){
int place;
int score[10];
int newScore=NULL;
char challenger[10][4];
char newChallenger[4];
if (argc > 2){
newScore = (int) strtol(argv[1], NULL, 10);
for (place=0;place<4;place++){
newChallenger[place] = argv[2][place];
}
newChallenger[3] = '\0';
}
FILE* hallOfFame = fopen("top10","r");
if (hallOfFame){
for (place=0;place<10;place++){
fread(&score[place],sizeof(int),1,hallOfFame);
fread(&challenger[place],sizeof(char),3,hallOfFame);
challenger[place][3]='\0';
}
fclose(hallOfFame);
printTop10(&score, &challenger);
for (place=0;place<10;place++){
if (newScore>score[place]){
inversionInt(&newScore, &score[place]);
inversionMot3(&newChallenger, &challenger[place]);
}
}
}
else{
printf("Le fichier n'as pas réussi à s'ouvrir pour la lecture\n");
}
hallOfFame = fopen("top10","w");
if (hallOfFame){
for (place=0;place<10;place++){
fwrite(&score[place],sizeof(int),1,hallOfFame);
fwrite(&challenger[place],sizeof(char),3,hallOfFame);
}
fclose(hallOfFame);
printTop10(&score, &challenger);
for (place=0;place<10;place++){
if (newScore>score[place]){
inversionInt(&newScore, &score[place]);
inversionMot3(&newChallenger, &challenger[place]);
}
}
fclose(hallOfFame);
}
else{
printf("Le fichier n'as pas réussi à s'ouvrir lors de sa réécriture\n");
}
return 0;
}

View File

@@ -0,0 +1,22 @@
#include<stdlib.h>
#include<stdio.h>
int main(void){
int place;
char nom[10][4];
int score[10];
FILE* hallOfFame = fopen("top10","r");
if (hallOfFame){
for (place=0;place<10;place++){
fread(&score[place],sizeof(int),1,hallOfFame);
printf("%09d",score[place]);
fread(&nom[place],sizeof(char),3,hallOfFame);
nom[place][3]='\0';
printf("%4s\n",nom[place]);
}
fclose(hallOfFame);
}
else{
printf("c'est toi qui est null\n");
}
return 0;
}

View File

View File

@@ -0,0 +1,21 @@
#include<stdlib.h>
#include<stdio.h>
#include<string.h>
int main(int argc, char** argv){
FILE* fichier = NULL;
char ligne[100];
int numLigne=0;
if (argc > 1){
fichier = fopen(argv[1],"r");
if (fichier){
for (numLigne=0; fgets(ligne,100,fichier)!=NULL; numLigne++){
printf("%d) %s",numLigne, ligne);
}
}
else{
printf("%s n'existe pas ou ne peut pas s'ouvrir",argv[1]);
}
}
return 0;
}

View File

@@ -0,0 +1,13 @@
#include<stdio.h>
int decToBin(char d){
printf("%d",(int)d);
return 0;
}
int main(int argc, char** argv){
char test = 'a';
charToBin(test);
return 0;
}

View File

BIN
DEV/DEV1.1_suite/Fichiers/exe Executable file

Binary file not shown.

View File

@@ -0,0 +1,84 @@
#include<stdlib.h>
#include<stdio.h>
#include<string.h>
int main(int argc, char** argv){
FILE* fichierScr = NULL;
FILE* fichierDes = NULL;
char caractere[2];
int arg=0;
if (argc > 2){
if (argc > 3){
arg++;
fichierDes = fopen(argv[3],"a");
}
else{
fichierDes = fopen(argv[2],"w");
}
fichierScr = fopen(argv[arg+1],"r");
if (fichierScr){
if (fichierDes){
while (fread(caractere,sizeof(char),1,fichierScr)!=0){
fwrite(caractere,sizeof(char),1,fichierDes);
}
return 0;
}
else{
printf("%s n'existe pas ou ne peut pas s'ouvrir\n",argv[2]);
return 1;
}
}
else{
printf("%s n'existe pas ou ne peut pas s'ouvrir\n",argv[1]);
return 1;
}
}
else{
printf("Utilisation: argv[0] <fichier_source> <fichier_destination>\n");
return 0;
}
}
#include<stdlib.h>
#include<stdio.h>
#include<string.h>
int main(int argc, char** argv){
FILE* fichierScr = NULL;
FILE* fichierDes = NULL;
char caractere[2];
int arg=0;
if (argc > 2){
if (argc > 3){
arg++;
fichierDes = fopen(argv[3],"a");
}
else{
fichierDes = fopen(argv[2],"w");
}
fichierScr = fopen(argv[arg+1],"r");
if (fichierScr){
if (fichierDes){
while (fread(caractere,sizeof(char),1,fichierScr)!=0){
fwrite(caractere,sizeof(char),1,fichierDes);
}
return 0;
}
else{
printf("%s n'existe pas ou ne peut pas s'ouvrir\n",argv[2]);
return 1;
}
}
else{
printf("%s n'existe pas ou ne peut pas s'ouvrir\n",argv[1]);
return 1;
}
}
else{
printf("Utilisation: argv[0] <fichier_source> <fichier_destination>\n");
return 0;
}
}

Binary file not shown.

View File

@@ -0,0 +1,62 @@
#include<stdio.h>
#include<stdlib.h>
// vérifie si le reel est déjà présent dans la liste
int verificateur(double* adresseDebut, double* adresseEmplacement){
while (adresseDebut<adresseEmplacement){
if (*adresseDebut==*adresseEmplacement){
return 0;
adresseDebut++;
}
return 1;
}
}
int main (void){
int nbReel;
int numReel=1;
double* adresseDebut;
double* adresseEmplacement;
double valeurSaisis;
printf("Choisissez le nombre de reel que vous voulez saisir : ");
scanf("%d",&nbReel);
adresseDebut = (double*) calloc(nbReel, sizeof (double));
adresseEmplacement = adresseDebut;
//lorsqu'il y a qu'un entier
if (nbReel==1){
printf("Saisissez votre reel : ");
scanf("%lf",adresseEmplacement);
printf("%lf %d\n",*adresseEmplacement, adresseEmplacement);
}
else{
// premier reels
if (nbReel>1){
printf("Saisissez votre 1er reel : ");
scanf("%lf",adresseEmplacement);
printf("%lf %d\n",*adresseEmplacement, adresseEmplacement);
// autres reels
for (numReel=2;numReel<nbReel;numReel++){
//adresseEmplacement++;
printf("Saisissez votre %deme reel : ",numReel);
scanf("%lf",&valeurSaisis);
if (verificateur(adresseDebut, adresseEmplacement)==1){
adresseEmplacement++;
*adresseEmplacement=valeurSaisis;
printf("%lf %d\n",*adresseEmplacement, adresseEmplacement);
}
}
// dernier reel
printf("Saisissez votre dernier reel : ");
scanf("%lf",&valeurSaisis);
if (verificateur(adresseDebut,adresseEmplacement)==1){
adresseEmplacement++;
*adresseEmplacement=valeurSaisis;
printf("%lf %d\n",*adresseEmplacement, adresseEmplacement);
}
}
}
for (;adresseEmplacement>=adresseDebut; adresseEmplacement--){
printf("%lf \n",*adresseEmplacement);
}
printf("\n");
}

View File

@@ -0,0 +1,35 @@
#include <stdio.h>
#include <stdlib.h>
#include<string.h>
char* inverse(const char* s){
int emplacementS;
int emplacementNewS;
char* newS;
emplacementS=strlen(s);
newS = malloc((emplacementS+1)*sizeof (char));
emplacementS--;
for (emplacementNewS=0; emplacementS>=0; emplacementS--, emplacementNewS++){
newS[emplacementNewS]=s[emplacementS];
}
newS[emplacementNewS+1]='\0';
return newS;
}
int main(int argc, char** argv)
{
int numArg;
char* p;
for (numArg=1;numArg<argc; numArg++){
p = (char*) inverse(argv[numArg]);
printf("%s ", argv[numArg]);
if (p==argv[numArg]){
printf("est un palindrome\n");
}
else{
printf("n'est pas un palindrome\n");
}
free(p);
}
return 0;
}

View File

@@ -0,0 +1,46 @@
#include<stdio.h>
#include<stdlib.h>
int premier(int nb){
int diviseur;
if (nb<2){
return 0;
}
if (nb==2){
return 1;
}
if (nb>2){
for (diviseur=2; diviseur<nb;diviseur++){
if (nb%diviseur==0){
return 0;
}
}
return 1;
}
}
int main(void){
int nbSaisis;
int* p= (int*) malloc(sizeof(int));
int taille=0;
int numPremier;
p[0]=2;
printf("Bonjour, dans ce programme, vous allez saisir des entier n positifs.\nVous aurez en réponse, le nième nombre premier.\nSaisissez 0 pour quitter.\n");
printf("Saisissez votre premier entier positif : ");
scanf("%d\n", &nbSaisis);
while (nbSaisis!=0) {
if (nbSaisis>taille){
p = (int*) realloc(p, nbSaisis*sizeof (int));
for (numPremier=taille;numPremier<nbSaisis;numPremier++){
int valPremier;
for (valPremier=p[numPremier-1]+1;premier(valPremier)!=1;valPremier++){}
p[numPremier]=valPremier;
}
taille=nbSaisis;
}
printf("%d\n",p[nbSaisis-1]);
printf("Saisissez un autre entier : ");
scanf("%d", &nbSaisis);
}
printf("Au revoir...");
}

View File

@@ -0,0 +1,46 @@
#include<stdio.h>
#include<stdlib.h>
int premier(int nb){
int diviseur;
if (nb<2){
return 0;
}
if (nb==2){
return 1;
}
if (nb>2){
for (diviseur=2; diviseur<nb;diviseur++){
if (nb%diviseur==0){
return 0;
}
}
return 1;
}
}
int main(void){
int nbSaisis;
int* p= (int*) malloc(sizeof(int));
int taille=0;
int numPremier;
p[0]=2;
printf("Bonjour, dans ce programme, vous allez saisir des entier n positifs.\nVous aurez en réponse, le nième nombre premier.\nSaisissez 0 pour quitter.\n");
printf("Saisissez votre premier entier positif : ");
scanf("%d\n", &nbSaisis);
while (nbSaisis!=0) {
if (nbSaisis>taille){
p = (int*) realloc(p, nbSaisis*sizeof (int));
for (numPremier=taille;numPremier<nbSaisis;numPremier++){
int valPremier;
for (valPremier=p[numPremier-1]+1;premier(valPremier)!=1;valPremier++){}
p[numPremier]=valPremier;
}
taille=nbSaisis;
}
printf("%d\n",p[nbSaisis-1]);
printf("Saisissez un autre entier : ");
scanf("%d", &nbSaisis);
}
printf("Au revoir...");
}

Binary file not shown.

View File

@@ -0,0 +1,31 @@
#include<stdlib.h>
#include<stdio.h>
#include<string.h>
int main(int argc, char** argv){
FILE* fichier = NULL;
char caractere[2];
int ligne=1;
if (argc > 1){
fichier = fopen(argv[1],"r");
if (fichier!=NULL){
while (fread(caractere,sizeof(char),1,fichier)!=0){
printf("%s",caractere);
if (caractere[0]=='\n'){
printf("%d) ",ligne);
ligne++;
}
}
printf("\n");
}
else{
fprintf(stderr,"impossible d'ouvrir le fichier %s\n",argv[1]);
return 0;
}
}
else{
fprintf(stderr,"Usage : %s <file>\n",argv[0]);
return 0;
}
return 1;
}

Binary file not shown.

View File

@@ -0,0 +1,63 @@
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
typedef struct m{
unsigned short valeur;
struct m* suivant;
} maillon;
void ajoutDebut(maillon** p_liste, unsigned short new_valeur){
maillon* new_maillon = (maillon*) malloc(sizeof(maillon));
new_maillon->valeur = new_valeur;
new_maillon->suivant = *p_liste;
*p_liste = new_maillon;
}
maillon* creerListe(int taille){
int i;
int valeur;
maillon* liste = NULL;
for (i=0; i<taille; i++){
valeur = (rand()%889)+111;
ajoutDebut(&liste, valeur);
}
return liste;
}
void supprListe(maillon* p_liste){
maillon* p_suivant=p_liste;
while (p_suivant!=NULL){
p_suivant = p_liste->suivant;
free(p_liste);
p_liste=p_suivant;
}
}
void affichage(maillon* liste){
maillon* addresse=liste;
int i;
for (i=0;i<10;i++){
printf("%hu\n",addresse->valeur);
addresse=addresse->suivant;
}
}
void plusGrand(maillon* liste){
int plusGrand=0;
maillon* element = liste;
while (element->suivant!=NULL){
element = element->suivant;
if (element->valeur > plusGrand){
plusGrand = element->valeur;
}
}
printf("plus grand : %d\n",plusGrand);
}
int main(void){
maillon* liste = NULL;
srand(time(NULL));
liste = creerListe(10);
affichage(liste);
plusGrand(liste);
supprListe(liste);
return 0;
}

View File

@@ -0,0 +1,60 @@
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
typedef struct m{
unsigned short valeur;
struct m* suivant;
} maillon;
void ajoutDebut(maillon** p_liste, unsigned short new_valeur){
maillon* new_maillon = (maillon*) malloc(sizeof(maillon));
new_maillon->valeur = new_valeur;
new_maillon->suivant = *p_liste;
*p_liste = new_maillon;
}
maillon* creerListe(int taille){
int i;
int valeur;
maillon* liste = NULL;
for (i=0; i<taille; i++){
valeur = (rand()%889)+111;
ajoutDebut(&liste, valeur);
}
return liste;
}
void supprListe(maillon* p_liste){
maillon* p_suivant=p_liste;
while (p_suivant!=NULL){
p_suivant = p_liste->suivant;
free(p_liste);
p_liste=p_suivant;
}
}
void affichage(maillon* liste){
maillon* addresse=liste;
int i;
for (i=0;i<10;i++){
printf("%hu\n",addresse->valeur);
addresse=addresse->suivant;
}
}
void plusGrand(maillon* liste){
int i;
int plusGrand=111;
maillon* suivant = liste;
while (p_suivant!=NULL){
suivant = liste->suivant;
if ()
}
}
int main(void){
maillon* liste = NULL;
srand(time(NULL));
liste = creerListe(10);
affichage(liste);
supprListe(liste);
return 0;
}

View File

@@ -0,0 +1,81 @@
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
typedef struct m{
int valeur;
struct m* suivant;
} maillon;
void ajoutDebut(maillon** p_liste, int new_valeur){
maillon* new_maillon = (maillon*) malloc(sizeof(maillon));
new_maillon->valeur = new_valeur;
new_maillon->suivant = *p_liste;
*p_liste = new_maillon;
}
maillon* creerListe(int taille){
int i;
int valeur;
maillon* liste = NULL;
for (i=0; i<taille; i++){
valeur = (rand()%889)+111;
ajoutDebut(&liste, valeur);
}
return liste;
}
void supprListe(maillon* p_liste){
maillon* p_suivant=p_liste;
while (p_suivant!=NULL){
p_suivant = p_liste->suivant;
free(p_liste);
p_liste=p_suivant;
}
}
void affichage(maillon* liste){
maillon* addresse=liste;
int i;
while (addresse->suivant!=NULL){
printf("%hu\n",addresse->valeur);
addresse=addresse->suivant;
}
}
void plusGrand(maillon* liste){
int plusGrand=0;
maillon* element = liste;
while (element->suivant!=NULL){
element = element->suivant;
if (element->valeur > plusGrand){
plusGrand = element->valeur;
}
}
printf("plus grand : %d\n",plusGrand);
}
void supprDer(maillon* liste){
if (liste!=NULL){
if (liste->suivant==NULL){
free(liste);
liste=NULL;
}
else{
maillon* p_element = liste;
while ((p_element->suivant)->suivant!=NULL){
p_element = p_element->suivant;
}
p_element->suivant=NULL;
free(p_element->suivant);
}
}
}
int main(void){
maillon* liste = NULL;
srand(time(NULL));
liste = creerListe(10);
affichage(liste);
plusGrand(liste);
supprDer(liste);
affichage(liste);
supprListe(liste);
return 0;
}

View File

@@ -0,0 +1,63 @@
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
typedef struct m{
unsigned short valeur;
struct m* suivant;
} maillon;
void ajoutDebut(maillon** p_liste, unsigned short new_valeur){
maillon* new_maillon = (maillon*) malloc(sizeof(maillon));
new_maillon->valeur = new_valeur;
new_maillon->suivant = *p_liste;
*p_liste = new_maillon;
}
maillon* creerListe(int taille){
int i;
int valeur;
maillon* liste = NULL;
for (i=0; i<taille; i++){
valeur = (rand()%889)+111;
ajoutDebut(&liste, valeur);
}
return liste;
}
void supprListe(maillon* p_liste){
maillon* p_suivant=p_liste;
while (p_suivant!=NULL){
p_suivant = p_liste->suivant;
free(p_liste);
p_liste=p_suivant;
}
}
void affichage(maillon* liste){
maillon* addresse=liste;
int i;
for (i=0;i<10;i++){
printf("%hu\n",addresse->valeur);
addresse=addresse->suivant;
}
}
void plusGrand(maillon* liste){
int plusGrand=0;
maillon* element = liste;
while (element->suivant!=NULL){
element = element->suivant;
if (element->valeur > plusGrand){
plusGrand = element->valeur;
}
}
printf("plus grand : %d\n",plusGrand);
}
int main(void){
maillon* liste = NULL;
srand(time(NULL));
liste = creerListe(10);
affichage(liste);
plusGrand(liste);
supprListe(liste);
return 0;
}

Binary file not shown.

View File

@@ -0,0 +1,34 @@
# 1 : BUT FINAL
but : exe
# 2 : VARIABLES
OFILES = chaine.o \
bouton.o \
jeu.o \
main.o
CC = gcc
CFLAGS = -Wall -g -lgraph
# 3 : DEPENDANCES (REGLES IMPLICITES)
bouton.o : chaine.h
jeu.o : chaine.h bouton.h
main.o : main.c chaine.h bouton.h jeu.h
#4 : DEPENDANCES AVEC COMMANDES
exe : $(OFILES)
$(CC) $(CFLAGS) -o exe $(OFILES)
#5 : NETTOYAGE DES FICHIERS GENERES
clean :
-rm -f $(OFILES) exe
#6 : BUTS FACTICES
.PHONY : but clean

View File

@@ -0,0 +1,32 @@
# 1 : BUT FINAL
but : exe
# 2 : VARIABLES
OFILES = chaine.o \
jeu.o \
main.o
CC = gcc
CFLAGS = -Wall -g -lgraph
# 3 : DEPENDANCES (REGLES IMPLICITES)
jeu.o : chaine.h
main.o : main.c chaine.h jeu.h
#4 : DEPENDANCES AVEC COMMANDES
exe : $(OFILES)
$(CC) $(CFLAGS) -o exe $(OFILES)
#5 : NETTOYAGE DES FICHIERS GENERES
clean :
-rm -f $(OFILES) exe
#6 : BUTS FACTICES
.PHONY : but clean

View File

@@ -0,0 +1,87 @@
#include<stdio.h>
#include<stdlib.h>
typedef struct m{
char valeur;
struct m* suivant;
} maillon;
typedef struct file{
maillon* debut;
maillon* fin;
}file;
int empty(file p_file){
if (p_file.debut){
return 1;
}
return 0;
}
void enqueue(file* p_file, char new_valeur){
maillon* new_maillon = (maillon*) malloc(sizeof(maillon));
new_maillon->valeur = new_valeur;
new_maillon->suivant = NULL;
if ((*p_file).debut==NULL){
p_file->debut = new_maillon;
}
else{
(p_file->fin)->suivant = new_maillon;
}
p_file->fin = new_maillon;
}
char dequeue(file* p_file){
maillon* p_suivant=(p_file->debut)->suivant;
char valeur = (p_file->debut)->valeur;
free(p_file->debut);
p_file->debut = p_suivant;
return valeur;
}
char old(file p_file){
return (p_file.debut)->valeur;
}
void clear(file* p_file){
maillon* p_suivant = (*p_file).debut;
while(p_suivant!=NULL){
p_suivant = ((*p_file).debut)->suivant;
free((*p_file).debut);
p_file->debut = p_suivant;
}
p_file->fin = NULL;
}
int main(void){
int choix=99;
char caractere;
file p_file;
p_file.debut=NULL;
p_file.fin=NULL;
printf("\n----------instruction----------\n1<char>- enqueue\n2- dequeue\n3- old\n4- clear\n5- quit\n----------------------------------\n");
while(choix!=5){
printf("choix : ");
scanf("%d%c",&choix,&caractere);
if (choix==1){
enqueue(&p_file,caractere);
}
if (choix==2){
if (empty(p_file)){
printf("resultat : %c\n",dequeue(&p_file));
}
}
if (choix==3){
if (empty(p_file)){
printf("resultat : %c\n",old(p_file));
}
}
if (choix==4){
clear(&p_file);
printf("La liste à bien été vidé\n");
}
}
clear(&p_file);
printf("O revoir BG\n");
return 0;
}

View File

@@ -0,0 +1,47 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <graph.h>
typedef struct bouton{
int xmin;
int xmax;
int ymin;
int ymax;
}bouton;
void creerBouton(bouton** boutons){
int numBouton, x, y;
*boutons= (bouton*) malloc(4*sizeof(bouton));
for (numBouton=0, y=100; y<300; y+=150){
for (x=100; x<300; x+=150, numBouton++){
(*boutons)[numBouton].xmin=x;
(*boutons)[numBouton].xmax=x+100;
(*boutons)[numBouton].ymin=y;
(*boutons)[numBouton].ymax=y+100;
//afficheBouton(boutons[numBouton],0,0);
}
}
}
void afficheBouton(bouton* boutons, int numBouton, int etat){
char chemin[21]="images/bouton?-?.png";
chemin[13]= (char) (numBouton+48);
chemin[15]= (char) (etat+48);
ChargerImage(chemin,boutons[numBouton].xmin,boutons[numBouton].ymin,0,0,100,100);
}
int detectClic(bouton* boutons, int choix){
int numBouton;
while(SourisCliquee());
while(1){
while (SourisCliquee()==0){}
for (numBouton=0;numBouton<4; numBouton++){
if (_X<boutons[numBouton].xmax && _X>boutons[numBouton].xmin && _Y<boutons[numBouton].ymax && _Y>boutons[numBouton].ymin){
afficheBouton(boutons,choix,0);
return numBouton;
}
}
}
}

View File

@@ -0,0 +1,49 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <graph.h>
typedef struct bouton{
int xmin;
int xmax;
int ymin;
int ymax;
}bouton;
void creerBouton(bouton** boutons){
int numBouton, x, y;
*boutons= (bouton*) malloc(4*sizeof(bouton));
for (numBouton=0, y=100; y<300; y+=150){
for (x=100; x<300; x+=150, numBouton++){
printf("%d) x=%d y=%d\n",numBouton,x,y);
boutons[numBouton]->xmin=x;
boutons[numBouton]->xmax=x+100;
boutons[numBouton]->ymin=y;
boutons[numBouton]->ymax=y+100;
printf("finis\n");
printf("%d %d %d %d\n",boutons[numBouton]->xmin,boutons[numBouton]->xmax,boutons[numBouton]->ymin,boutons[numBouton]->ymax);
}
}
}
void afficheBouton(bouton* boutons, int numBouton, int etat){
char chemin[21]="images/bouton?-?.png";
chemin[13]= (char) numBouton+48;
chemin[13]= etat;
ChargerImage(chemin,boutons[numBouton].xmin,boutons[numBouton].ymin,0,0,100,100);
}
int detectClic(bouton* boutons, int choix){
int numBouton;
while(SourisCliquee());
while(1){
while (SourisCliquee()==0){}
for (numBouton=0;numBouton<4; numBouton++){
if (_X<boutons[numBouton].xmax && _X>boutons[numBouton].xmin && _Y<boutons[numBouton].ymax && _Y>boutons[numBouton].ymin){
afficheBouton(boutons,choix,0);
return numBouton;
}
}
}
}

View File

@@ -0,0 +1,14 @@
#ifndef BOUTON_H
#define BOUTON_H
typedef struct bouton{
int xmin;
int xmax;
int ymin;
int ymax;
}bouton;
void creerBouton(bouton** boutons);
int detectClic(bouton* boutons, int choix);
void afficheBouton(bouton* boutons, int numBouton, int etat);
#endif

View File

@@ -0,0 +1,14 @@
#ifndef BOUTON_H
#define BOUTON_H
typedef struct bouton{
int xmin;
int xmax;
int ymin;
int ymax;
}bouton;
void creerBouton(bouton** boutons);
int detectClic(bouton* boutons, int choix);
void afficheBouton(bouton* boutons, int numBouton, int etat);
#endif

Binary file not shown.

View File

@@ -0,0 +1,95 @@
#include<stdio.h>
#include<stdlib.h>
typedef struct maillon{
int valeur;
struct maillon* suivant;
} maillon;
typedef struct file{
maillon* debut;
maillon* fin;
}file;
int empty(file p_file){
if (p_file.debut){
return 1;
}
return 0;
}
void creerFile(file* p_file){
p_file->debut=NULL;
p_file->fin=NULL;
}
void enqueue(file* p_file, int new_valeur){
maillon* new_maillon = (maillon*) malloc(sizeof(maillon));
new_maillon->valeur = new_valeur;
new_maillon->suivant = NULL;
if (p_file->debut==NULL){
p_file->debut = new_maillon;
}
else{
(p_file->fin)->suivant = new_maillon;
}
p_file->fin = new_maillon;
}
int dequeue(file* p_file){
maillon* p_suivant=(p_file->debut)->suivant;
int valeur = (p_file->debut)->valeur;
free(p_file->debut);
p_file->debut = p_suivant;
return valeur;
}
int first(file p_file){
return (p_file.debut)->valeur;
}
void clear(file* p_file){
maillon* p_suivant = (*p_file).debut;
while(p_suivant!=NULL){
p_suivant = ((*p_file).debut)->suivant;
free((*p_file).debut);
p_file->debut = p_suivant;
}
p_file->fin = NULL;
}
/*
int main(void){
int choix=99;
int caractere;
file p_file;
creerFile(&p_file);
printf("\n----------instruction----------\n1<char>- enqueue\n2- dequeue\n3- old\n4- clear\n5- quit\n----------------------------------\n");
while(choix!=5){
printf("choix : ");
scanf(" %d",&choix);
if (choix==1){
printf("nombre : ");
scanf(" %d",&caractere);
enqueue(&p_file,caractere);
}
if (choix==2){
if (empty(p_file)){
printf("resultat : %d\n",dequeue(&p_file));
}
}
if (choix==3){
if (empty(p_file)){
printf("resultat : %d\n",first(p_file));
}
}
if (choix==4){
clear(&p_file);
printf("La liste à bien été vidé\n");
}
}
clear(&p_file);
printf("O revoir BG\n");
return 0;
}
*/

View File

@@ -0,0 +1,93 @@
#include<stdio.h>
#include<stdlib.h>
typedef struct maillon{
char valeur;
struct maillon* suivant;
} maillon;
typedef struct file{
maillon* debut;
maillon* fin;
}file;
int empty(file p_file){
if (p_file.debut){
return 1;
}
return 0;
}
void creerFile(file* p_file){
p_file->debut=NULL;
p_file->fin=NULL;
}
void enqueue(file* p_file, char new_valeur){
maillon* new_maillon = (maillon*) malloc(sizeof(maillon));
new_maillon->valeur = new_valeur;
new_maillon->suivant = NULL;
if ((*p_file).debut==NULL){
p_file->debut = new_maillon;
}
else{
(p_file->fin)->suivant = new_maillon;
}
p_file->fin = new_maillon;
}
char dequeue(file* p_file){
maillon* p_suivant=(p_file->debut)->suivant;
char valeur = (p_file->debut)->valeur;
free(p_file->debut);
p_file->debut = p_suivant;
return valeur;
}
char first(file p_file){
return (p_file.debut)->valeur;
}
void clear(file* p_file){
maillon* p_suivant = (*p_file).debut;
while(p_suivant!=NULL){
p_suivant = ((*p_file).debut)->suivant;
free((*p_file).debut);
p_file->debut = p_suivant;
}
p_file->fin = NULL;
}
/*
int main(void){
int choix=99;
char caractere;
file p_file;
creerFile(&p_file);
printf("\n----------instruction----------\n1<char>- enqueue\n2- dequeue\n3- old\n4- clear\n5- quit\n----------------------------------\n");
while(choix!=5){
printf("choix : ");
scanf("%d%c",&choix,&caractere);
if (choix==1){
enqueue(&p_file,caractere);
}
if (choix==2){
if (empty(p_file)){
printf("resultat : %c\n",dequeue(&p_file));
}
}
if (choix==3){
if (empty(p_file)){
printf("resultat : %c\n",first(p_file));
}
}
if (choix==4){
clear(&p_file);
printf("La liste à bien été vidé\n");
}
}
clear(&p_file);
printf("O revoir BG\n");
return 0;
}
*/

Some files were not shown because too many files have changed in this diff Show More