diff --git a/.gitignore b/.gitignore index 3417814..97d8f0d 100644 --- a/.gitignore +++ b/.gitignore @@ -73,3 +73,5 @@ tags # Persistent undo [._]*.un~ +DEV1.1/meliani_CM1.tar.gz +DEV1.1S/meliani_CM3.tar.gz diff --git a/DEV1.1/CM1/calculs.c b/DEV1.1/CM1/calculs.c new file mode 100644 index 0000000..7cec12a --- /dev/null +++ b/DEV1.1/CM1/calculs.c @@ -0,0 +1,27 @@ +#include +#include +#include +int main(void){ + int NOMBRE = 5; + double CIBLE = 51.7; + double tab[NOMBRE]; + int i; + double res = 100000; + int proche = 0; + for(i = 0; i< NOMBRE; i++){ + printf("Entrez une valeur : "); + scanf("%lf", &tab[i]); + printf("case n° %d : ", i); + printf("%.2lf\n", tab[i]); + } + res = fabs(tab[0] - CIBLE); + for(i = 1; i < NOMBRE; i++){ + if (fabs(tab[i] - CIBLE) <= res){ + res = fabs(tab[i] - CIBLE); + proche = i; + } + } + printf("La valeur la plus proche est dans la case n° %d\n", proche); + return 0; +} + \ No newline at end of file diff --git a/DEV1.1/CM1/cases.c b/DEV1.1/CM1/cases.c new file mode 100644 index 0000000..c7951d6 --- /dev/null +++ b/DEV1.1/CM1/cases.c @@ -0,0 +1,26 @@ +#include +#include +int main(void){ + int cases; + int i; + int a; + printf("Entrez le nombre de cases : "); + scanf("%d", &cases); + if (cases > 0){ + printf("┌──"); + for(i=0; i < cases-1; i++){ + printf("┬──"); + } + printf("┐\n"); + for(i=0; i <= cases; i++){ + printf("│ "); + } + printf("\n"); + printf("└──"); + for(i=0; i< cases-1; i++){ + printf("┴──"); + } + printf("┘\n"); + } + return 0; +} \ No newline at end of file diff --git a/DEV1.1/CM1/chaton.c b/DEV1.1/CM1/chaton.c new file mode 100644 index 0000000..eca136e --- /dev/null +++ b/DEV1.1/CM1/chaton.c @@ -0,0 +1,8 @@ +#include +#include +int main(void){ + printf(" (\\_/)\n"); + printf("=(^.^)=\n"); + printf("(\")_(\")"); + return 0; +} \ No newline at end of file diff --git a/DEV1.1/CM1/comptes.c b/DEV1.1/CM1/comptes.c new file mode 100644 index 0000000..e07c8ba --- /dev/null +++ b/DEV1.1/CM1/comptes.c @@ -0,0 +1,47 @@ +#include +#include +int main(void){ + int argent; + int livre = 0; + int deniers = 0; + int sous = 0; + printf("Combien de deniers ? \n"); + scanf("%d", &argent); + while (argent >= 240){ + livre++; + argent = argent-240; + } + while (argent >=12){ + sous++; + argent = argent-12; + } + while (argent >= 1){ + deniers++; + argent = argent-1; + } + if(livre != 0 && livre == 1){ + printf("%d", livre); + printf(" livre\n"); + } + if(livre > 1){ + printf("%d", livre); + printf(" livres\n"); + } + if(sous != 0 && sous == 1){ + printf("%d", sous); + printf(" sou\n"); + } + if(sous > 1){ + printf("%d", sous); + printf(" sous\n"); + } + if(deniers != 0 && deniers == 1){ + printf("%d", deniers); + printf(" denier"); + } + if(deniers > 1){ + printf("%d", deniers); + printf(" deniers"); + } + return 0; +} \ No newline at end of file diff --git a/DEV1.1/CM1/constante.c b/DEV1.1/CM1/constante.c new file mode 100644 index 0000000..86446f3 --- /dev/null +++ b/DEV1.1/CM1/constante.c @@ -0,0 +1,13 @@ +#include +#include +int main(void){ + char a = (char) '9'; + printf("%c\n", a); + long int b = 9L; + printf("%ld\n", b); + long double c = 9.0L; + printf("%.0Lf\n", c); + int d = 0x9; + printf("%d\n", d); + return 0; +} \ No newline at end of file diff --git a/DEV1.1S/CM/MakeFile b/DEV1.1S/CM/MakeFile new file mode 100644 index 0000000..a905706 --- /dev/null +++ b/DEV1.1S/CM/MakeFile @@ -0,0 +1,8 @@ +exo1 : fonction.o exo1.o + gcc -o exo1 fonction.o exo1.o + +fonction.o : fonction.c fonction.h + gcc -c fonction.c + +exo.o : exo1.c exo1.h + gcc -c exo1.c \ No newline at end of file diff --git a/DEV1.1S/CM/exo1.c b/DEV1.1S/CM/exo1.c new file mode 100644 index 0000000..d712938 --- /dev/null +++ b/DEV1.1S/CM/exo1.c @@ -0,0 +1,17 @@ +#include +#include +#include +#include + +int main(int argc, char *argv[]){ + double tab[10]; + int i; + for(i=1; i +#include + +int main(int argc, char *argv[]){ + FILE* fichier1, fichier2; + char tab1, tab2; + int diff; + fichier1 = fopen($argv[1], "r"); + fichier2 = fopen($argv[2], "r") + while(diff != 0){ + fread(&tab1, sizeof(char), 1, fichier1) + fread(&tab2, sizeof(char), 1, fichier2) + if (strcmp(tab2,tab1) != 0;){ + diff = 1; + } + } + fclose(fichier1); + fclose(fichier2); + return 0; +} diff --git a/DEV1.1S/CM/exo3.c b/DEV1.1S/CM/exo3.c new file mode 100644 index 0000000..af38e92 --- /dev/null +++ b/DEV1.1S/CM/exo3.c @@ -0,0 +1,22 @@ +#include +#include +#include +int main(int argc, char *argv[]){ + struct timespec temps; + + printf("E"); + temps.tv_nsec; + printf("R"); + temps.tv_nsec; + printf("R"); + temps.tv_nsec; + + printf("E"); + temps.tv_nsec; + + printf("U"); + temps.tv_nsec; + + printf("R"); + return 0 +} \ No newline at end of file diff --git a/DEV1.1S/CM/fonction.c b/DEV1.1S/CM/fonction.c new file mode 100644 index 0000000..b422d34 --- /dev/null +++ b/DEV1.1S/CM/fonction.c @@ -0,0 +1,13 @@ +#include +#include +#include +int valnull(double* tab, int taille){ + int i; + int accumulateur = 0; + for(i=0; i +#include +int rechercheValeur(int valeur, int* tableau, int taille){ + int n= -1; + if (taille == 0){ + if (valeur == tableau[taille]){ + n = taille; + } + return n; + } + if (valeur == tableau[taille]){ + n = taille; + return n; + } + return rechercheValeur(valeur, tableau , taille-1); +} +int main(int argc, char const *argv[]) +{ + int test, test1, test2, test3, test4; + int oui = 5; + int tab1[5] = {3, 7 ,4 ,8, 9}; + int tab2[5] = {6, 7 ,4 ,8, 9}; + int tab3[5] = {2, 7 ,4 ,8, 6}; + int tab4[5] = {6, 7 ,6 ,6, 9}; + test = rechercheValeur(6, tab1 , oui); + test2 = rechercheValeur(6, tab2, oui); + test3 = rechercheValeur(6, tab3, oui); + test4 = rechercheValeur(6, tab4, oui); + + printf("Test vide : "); + printf("%d\n", test); + + printf("Test 1 fois au début : "); + printf("%d\n", test2); + + printf("Test 1 fois a la fin : "); + printf("%d\n", test3); + + printf("Test 3 fois au total : "); + printf("%d\n", test4); + + + return 0; +} diff --git a/DEV1.1S/CM3/recoupement.c b/DEV1.1S/CM3/recoupement.c new file mode 100644 index 0000000..24cd304 --- /dev/null +++ b/DEV1.1S/CM3/recoupement.c @@ -0,0 +1,29 @@ +#include +#include +int main(int argc, char const *argv[]) +{ + int* chiffres; + int valeur; + int arret = 0; + int accumulateur = 0; + int i; + chiffres = (int*) malloc(100*sizeof(int)); + while(arret == 0){ + for(i=0; i<= accumulateur; i++){ + if ((chiffres[accumulateur] / chiffres[i]) == 2){ + arret == 1; + printf("Perdu)"); + i == 100000000; + } + + } + if (arret != 1){ + printf("Entrez une valeur : "); + scanf("%d", valeur); + chiffres[accumulateur] == valeur; + } + +} + + return EXIT_SUCCESS; +} \ No newline at end of file diff --git a/DEV1.1S/CM3/reduction.c b/DEV1.1S/CM3/reduction.c new file mode 100644 index 0000000..9626ddb --- /dev/null +++ b/DEV1.1S/CM3/reduction.c @@ -0,0 +1,26 @@ +#include +#include +#include +#include + +void sans_zero(stack pile){ + int stock; + while (empty(pile) == 0){ + stock = pop(pile); + if(stock != 0){ + push(pile, stock) + } + + } +} +int main(int argc, char const *argv[]) +{ + int pile = create_stack() + int push = push(pile, 1); + push = push(pile , 2); + push = push(pile , 0); + push = push(pile , 1); + push = push(pile , 0); + sans_zero(pile); + return 0; +} \ No newline at end of file diff --git a/DEV1.1S/CM3/stack.c b/DEV1.1S/CM3/stack.c new file mode 100644 index 0000000..6321919 --- /dev/null +++ b/DEV1.1S/CM3/stack.c @@ -0,0 +1,60 @@ +#include +#include "stack.h" + +struct s_link { + unsigned value; + struct s_link *next; +}; + +typedef struct s_link link; + +struct s_stack { + link *first; +}; + + +/* crée une pile vide */ +stack create_stack(void) { + return (stack) calloc(1, sizeof(struct s_stack)); +} + +/* ajoute un élément à la pile. Renvoie 1 en cas de succès */ +int push(stack the_stack, unsigned the_value) { + link *new = (link*) malloc(sizeof(link)); + if (new == NULL) { + return 0; + } + new->value = the_value; + new->next = the_stack->first; + the_stack->first = new; + return 1; +} + +/* renvoie 1 si la pile est vide */ +int empty(stack the_stack) { + return the_stack->first == NULL; +} + +/* retire un élément de la pile. Renvoie l'élément retiré, ou -1 en cas d'échec */ +long pop(stack the_stack) { + if(the_stack->first == NULL) { + return -1; + } + link l = *(the_stack->first); + free(the_stack->first); + the_stack->first = l.next; + return l.value; +} + +/* détruit une pile en libérant les ressources associées */ +void destroy_stack(stack the_stack) { + link *current, *saved; + + current = the_stack->first; + while(current != NULL) { + saved = current->next; + free(current); + current = saved; + } + free(the_stack); +} \ No newline at end of file diff --git a/DEV1.1S/CM3/stack.h b/DEV1.1S/CM3/stack.h new file mode 100644 index 0000000..81897ac --- /dev/null +++ b/DEV1.1S/CM3/stack.h @@ -0,0 +1,22 @@ +#ifndef STACK_H +#define STACK_H + +/* le type stack représente une pile */ +typedef struct s_stack *stack; + +/* crée une pile vide. Renvoie NULL en cas d'échec */ +stack create_stack(void); + +/* ajoute un élément à la pile. Renvoie 0 en cas d'échec */ +int push(stack, unsigned); + +/* renvoie 1 si la pile est vide */ +int empty(stack); + +/* retire un élément de la pile. Renvoie l'élément retiré, ou -1 en cas d'échec */ +long pop(stack); + +/* détruit une pile en libérant les ressources associées */ +void destroy_stack(stack); + +#endif /* STACK_H */ \ No newline at end of file diff --git a/DEV1.1S/Controle_Blanc/Exo1.c b/DEV1.1S/Controle_Blanc/Exo1.c new file mode 100644 index 0000000..61fdd29 --- /dev/null +++ b/DEV1.1S/Controle_Blanc/Exo1.c @@ -0,0 +1,18 @@ +#include +#include +#include +int main(int argc, char const *argv[]) +{ + if (strcmp(argv[2], "cm") == 0){ + double val =strtod(argv[1], NULL); + val = val / 2.54; + printf("%.2lf%s", val,"in"); + + } + if (strcmp(argv[2], "in") == 0){ + double val = strtod(argv[1], NULL); + val = val*2.54; + printf("%.2lf%s",val,"cm"); + } + return EXIT_SUCCESS; +} \ No newline at end of file diff --git a/DEV1.1S/Controle_Blanc/Exo2.c b/DEV1.1S/Controle_Blanc/Exo2.c new file mode 100644 index 0000000..5480d91 --- /dev/null +++ b/DEV1.1S/Controle_Blanc/Exo2.c @@ -0,0 +1,46 @@ +#include +#include +#include +#include +int main(int argc, char const *argv[]){ + int date; + int mois; + int annee; + printf("Entrez une date : "); + scanf("%d", &date); + scanf("%d", &mois); + scanf("%d", &annee); + struct tm jour; + jour.tm_sec = 0; + jour.tm_min = 0; + jour.tm_hour = 0; + jour.tm_mday = date; + jour.tm_mon = mois; + jour.tm_year = annee; + printf("%d\n", jour.tm_wday); + if (jour.tm_wday == 0){ + printf("c'est un dimanche"); + } + if (jour.tm_wday == 1){ + printf("c'est un lundi"); + } + if (jour.tm_wday == 2){ + printf("c'est un mardi"); + } + if (jour.tm_wday == 3){ + printf("c'est un mercredi"); + } + if (jour.tm_wday == 4){ + printf("c'est un jeudi"); + } + if (jour.tm_wday == 5){ + printf("c'est un vendredi"); + } + if (jour.tm_wday == 6){ + printf("c'est un samedi"); + } + + + + return 0; +} \ No newline at end of file diff --git a/DEV1.1S/Controle_Blanc/Exo3.c b/DEV1.1S/Controle_Blanc/Exo3.c new file mode 100644 index 0000000..9a40f80 --- /dev/null +++ b/DEV1.1S/Controle_Blanc/Exo3.c @@ -0,0 +1,12 @@ +#include +#include +#include +int main (void){ + FILE* fichier; + fichier = fopen("dev/random", "r"); + int tab[2]; + fread(&tab[0],sizeof(int),1,fichier); + printf("%d\n", tab[0]); + fclose(fichier); + return 0; +} \ No newline at end of file diff --git a/DEV1.1S/Controle_Blanc/mail.txt b/DEV1.1S/Controle_Blanc/mail.txt new file mode 100644 index 0000000..97171c4 --- /dev/null +++ b/DEV1.1S/Controle_Blanc/mail.txt @@ -0,0 +1 @@ +marie-helene.renaud@u-pec.fr diff --git a/DEV1.1S/TP01/Palindromes.c b/DEV1.1S/TP01/Palindromes.c new file mode 100644 index 0000000..f94acf7 --- /dev/null +++ b/DEV1.1S/TP01/Palindromes.c @@ -0,0 +1,30 @@ +#include +#include +#include + +char* inverse(const char* s){ + int i; + int e=0; + char* crocs; + int longueur = (int) strlen(s); + crocs = (char*) malloc(longueur+1); + for (i=longueur-1;i>=0;--i) { + crocs[e] = s[i]; + e++; + crocs[longueur] = '\0'; + } + return crocs; +} + +int main(int argc, char** argv) { + int c; + for(c=1; c< argc; c++){ + if (strcmp(argv[c], inverse(argv[c]))== 0){ + printf("est un palindrome \n"); + } + else{ + printf("non \n"); + } + } + return 0; +} \ No newline at end of file diff --git a/DEV1.1S/TP01/singleton.c b/DEV1.1S/TP01/singleton.c new file mode 100644 index 0000000..7ea745e --- /dev/null +++ b/DEV1.1S/TP01/singleton.c @@ -0,0 +1,43 @@ +#include +#include +int main(void){ + float* tab; + int i = 0; + int a; + int fin = 0; + int lin = 2; + int valeur; + tab = (float*) malloc(2*sizeof(float)); + printf("Donnez une réponse : "); + valeur = scanf("%f", &tab[i]); + if(valeur == 1){ + i++; + } + while(valeur != 1){ + printf("Donnez une valeur : "); + valeur = scanf("%f", tab[i]); + if (valeur == 1 ){ + i++; + } + if (i%2 == 0){ + lin = lin +2; + tab = (float*) realloc(tab, lin); + } + int taille = strlen(tab); + } + for(i=0;i +#include +#include +int main(void){ + struct crocs{ + double x; + double y; + double i = sqrt(-1); + double z = x+y*i; + } + double val1; + double val2; + double res; + double eee; + printf("Donnez une valeur : "); + scanf("%f", &val1); + printf("Donnez une deuxième valeur : "); + scanf("%f", &val2); + struct crocs cars = {val1;val2;eee;res} + printf("%f", res); + return EXIT_SUCCESS; +} \ No newline at end of file diff --git a/DEV1.1S/TP02/date.c b/DEV1.1S/TP02/date.c new file mode 100644 index 0000000..171c2f3 --- /dev/null +++ b/DEV1.1S/TP02/date.c @@ -0,0 +1,14 @@ +#include +#include +#include +int main(void){ + time_t temps= time(NULL); + struct tm* date = localtime(&temps); + printf("%d", date->tm_year+1900); + printf("-"); + printf("%d", date->tm_mon+1); + printf("-"); + printf("%d\n", date->tm_mday); + return EXIT_SUCCESS; +} + diff --git a/DEV1.1S/TP02/groupe.c b/DEV1.1S/TP02/groupe.c new file mode 100644 index 0000000..2a68fa6 --- /dev/null +++ b/DEV1.1S/TP02/groupe.c @@ -0,0 +1,14 @@ +#include +#include +#include +#include +#include +int main(void){ + int i = 0; + struct group* groupe = getgrnam("students22"); + while(groupe->gr_mem[i] != NULL){ + printf("%s", groupe->gr_mem[i]); + i++; + } + return EXIT_SUCCESS; +} \ No newline at end of file diff --git a/DEV1.1S/TP02/tailles.c b/DEV1.1S/TP02/tailles.c new file mode 100644 index 0000000..faabdb1 --- /dev/null +++ b/DEV1.1S/TP02/tailles.c @@ -0,0 +1,15 @@ +#include +#include +int main(void){ + struct tailles{ + char* a; + char* b; + char* c; + }; + struct tailles chaine = {"e","ab","c"}; + int res = sizeof(chaine); + printf("%d\n", res); + return EXIT_SUCCESS; +} + + \ No newline at end of file diff --git a/DEV1.1S/TP03/challenger.c b/DEV1.1S/TP03/challenger.c new file mode 100644 index 0000000..a6a7f29 --- /dev/null +++ b/DEV1.1S/TP03/challenger.c @@ -0,0 +1,59 @@ +#include +#include +#include +int main(void){ + FILE* fichier; + fichier = fopen("top10", "r"); + int tab[10]; + char oui[30]; + int i; + int a; + int alt = 4; + for(i=0; i<10; i++){ + fread(&tab[i], sizeof(int), 1,fichier); + fread(&oui[i*3], 1, 3, fichier); + } + for(i=0; i<10;i++){ + printf("%9d ", tab[i]); + printf("%c", oui[i*3]); + printf("%c", oui[i*3+1]); + printf("%c\n", oui[i*3+2]); + } + fclose(fichier); + int score; + char pseudo; + int emplacement; + printf("Donnez un score : "); + scanf("%7d", &score); + printf("Donnez un pseudo : "); + scanf("%c", &pseudo); + if(strlen(pseudo) != 3){ + scanf("%c", &pseudo); + } + + for(i=0; i<10; i++){ + if (score > tab[i]){ + emplacement = i; + i =10; + } + } + for(i=10; i>=emplacement; i--){ + tab[i] == tab[i]+1; + } + tab[emplacement] = score; + emplacement = emplacement+3; + for(i=30; i<= emplacement; i--){ + oui[i] == oui[i+3]; + } + for(i=0; i<3; i++){ + oui[emplacement] == pseudo[i]; + emplacement++; + } + printf("%d",tab); + printf("%c", oui); + return EXIT_SUCCESS; +} +/*[004867123,41545574] +[B,O,B,<,O,>] +004867123 BOB +41545574 */ \ No newline at end of file diff --git a/DEV1.1S/TP03/records.c b/DEV1.1S/TP03/records.c new file mode 100644 index 0000000..5d1bc44 --- /dev/null +++ b/DEV1.1S/TP03/records.c @@ -0,0 +1,27 @@ +#include +#include +int main(void){ + FILE* fichier; + fichier = fopen("top10", "r"); + int tab[10]; + char oui[30]; + int i; + int a; + int alt = 4; + for(i=0; i<10; i++){ + fread(&tab[i], sizeof(int), 1,fichier); + fread(&oui[i*3], 1, 3, fichier); + } + for(i=0; i<10;i++){ + printf("%9d ", tab[i]); + printf("%c", oui[i*3]); + printf("%c", oui[i*3+1]); + printf("%c\n", oui[i*3+2]); + } + fclose(fichier); + return EXIT_SUCCESS; +} +/*[004867123,41545574] +[B,O,B,<,O,>] +004867123 BOB +41545574 */ \ No newline at end of file diff --git a/DEV1.1S/TP03/top10 b/DEV1.1S/TP03/top10 new file mode 100644 index 0000000..f6c571a Binary files /dev/null and b/DEV1.1S/TP03/top10 differ diff --git a/DEV1.1S/TPLC/exo1.c b/DEV1.1S/TPLC/exo1.c new file mode 100644 index 0000000..25fba56 --- /dev/null +++ b/DEV1.1S/TPLC/exo1.c @@ -0,0 +1,42 @@ +-0.ZP+#include +#include +#include + +struct mail{ + int valeur; + struct mail* suivant; +}; +typedef struct mail maillon; + +void afficher(maillon* premier) { + maillon* p; + for(p = premier; p != NULL; p = p->suivant) + printf("%d ", p->valeur); +} + +maillon* ajouter_debut(maillon* premier, int nouveau) { + maillon* p = (maillon*) malloc(sizeof(maillon)); + if (p) { + p->suivant = premier; + p->valeur = nouveau; + } + return p; +} +int main(int argc, char const *argv[]){ + maillon* vide= NULL; + srand(time(NULL)); + int i; + int stock; + int maximilien = 111; + for(i=0; i<10; i++){ + stock = 111+random()%889; + vide = ajouter_debut(vide , stock); + if(stock > maximilien){ + maximilien = stock; + } + } + afficher(vide); + printf("\n%d\n", maximilien); + + return 0; +} diff --git a/DEV1.1S/TPLC/exo2.c b/DEV1.1S/TPLC/exo2.c new file mode 100644 index 0000000..ba7b95d --- /dev/null +++ b/DEV1.1S/TPLC/exo2.c @@ -0,0 +1,42 @@ +#include +#include +#include + +struct mail{ + int valeur; + struct mail* suivant; +}; +typedef struct mail maillon; + +void afficher(maillon* premier) { + maillon* p; + for(p = premier; p != NULL; p = p->suivant) + printf("%d ", p->valeur); +} + +maillon* ajouter_debut(maillon* premier, int nouveau) { + maillon* p = (maillon*) malloc(sizeof(maillon)); + if (p) { + p->suivant = premier; + p->valeur = nouveau; + } + return p; +} +int main(int argc, char const *argv[]){ + maillon* vide= NULL; + srand(time(NULL)); + int i; + int stock; + int maximilien = 111; + for(i=0; i<10; i++){ + stock = 111+random()%889; + vide = ajouter_debut(vide , stock); + if(stock > maximilien){ + maximilien = stock; + } + } + afficher(vide); + printf("\n%d\n", maximilien); + + return 0; +} diff --git a/DEV1.1S/TPLC/test.c b/DEV1.1S/TPLC/test.c new file mode 100644 index 0000000..9ad285c --- /dev/null +++ b/DEV1.1S/TPLC/test.c @@ -0,0 +1,52 @@ +#include +#include + +struct mail{ + int valeur; + struct mail* suivant; +}; +typedef struct mail maillon; + +void afficher(maillon* premier) { + maillon* p; + for(p = premier; p != NULL; p = p->suivant) + printf("%d ", p->valeur); +} + +maillon* ajouter_debut(maillon* premier, int nouveau) { + maillon* p = (maillon*) malloc(sizeof(maillon)); + if (p) { + p->suivant = premier; + p->valeur = nouveau; + } + return p; +} + +void delete(int v, maillon* vide){ + maillon* m; + m=vide; + int i; + for (i=0;isuivant; + } + free(m->suivant); + m->suivant=NULL; +} + + +int main(int argc, char const *argv[]){ + maillon* vide= NULL; + maillon* m; + int i; + for(i=1; i<4; i++){ + vide = ajouter_debut(vide , i); + } + afficher(vide); + printf("\n"); + delete(3, vide); + afficher(vide); + printf("\n"); + return 0; +} + +/*Q7d8s6dp&#*/ \ No newline at end of file diff --git a/DEV1.1S/TPPILE/chainee.c b/DEV1.1S/TPPILE/chainee.c new file mode 100644 index 0000000..597c597 --- /dev/null +++ b/DEV1.1S/TPPILE/chainee.c @@ -0,0 +1,44 @@ +#include +#include + +struct maillon_ { + char c; + struct maillon_* prev; +}; + +typedef struct maillon_ maillon; +typedef maillon* pile; + +void push(pile* p, char c) { + maillon* m = calloc(1, sizeof(maillon)); + m->c = c; + m->prev = *p; + + *p = m; +} + +char pop(pile* p) { + char c = (*p)->c; + *p = (*p)->prev; + return c; +} + +int empty(pile p) { + return p == NULL; +} + +char top(pile p) { + return p->c; +} + +void clear(pile* p) { + *p = NULL; +} + +pile create() { + return NULL; +} + +void destroy(pile* p) { + free(p); +} \ No newline at end of file diff --git a/DEV1.1S/TPPILE/chainee_tables.c b/DEV1.1S/TPPILE/chainee_tables.c new file mode 100644 index 0000000..d4fbccd --- /dev/null +++ b/DEV1.1S/TPPILE/chainee_tables.c @@ -0,0 +1,47 @@ +#include +#include + +struct pile_ { + char* tab; + int size; +}; + +typedef struct pile_ pile; + +void push(pile* p, char c) { + (p->tab)[p->size] = c; + p->size++; + p->tab = realloc(p->tab, (p->size)+1); +} + +char pop(pile* p) { + char c = (p->tab)[p->size-1]; + p->size--; + p->tab = realloc(p->tab, (p->size)+1); + return c; +} + +int empty(pile p) { + return p.size == 0; +} + +char top(pile p) { + return (p.tab)[(p.size) - 1]; +} + +void clear(pile* p) { + free(p->tab); + p->tab = calloc(1, sizeof(int)); + p->size = 0; +} + +pile create() { + pile* p = (calloc(1, sizeof(pile))); + p->tab = calloc(1, sizeof(char)); + p->size = 0; + return *p; +} + +pile destroy(pile* p) { + free(p); +} \ No newline at end of file diff --git a/DEV1.1S/TPPILE/file.c b/DEV1.1S/TPPILE/file.c new file mode 100644 index 0000000..bb4f23a --- /dev/null +++ b/DEV1.1S/TPPILE/file.c @@ -0,0 +1,34 @@ +#include +#include + +struct maillon_ { + char c; + struct maillon_* next; +}; + +typedef struct maillon_ maillon; +typedef maillon* file; + +void push(file* f, char c) { + maillon* m = calloc(1, sizeof(maillon)); + m->c = c; + + if (*f == NULL) { + *f = m; + } else { + file* start = f; + file ff = *f; + while (ff->next != NULL) ff = ff->next; + ff->next = m; + f = start; + } +} + +char pop(file* f) { + char c = (*f)->c; + *f = (*f)->next; +} + +int empty(file f) { + return f == NULL; +} \ No newline at end of file diff --git a/DEV1.1S/TPREC/exo2.c b/DEV1.1S/TPREC/exo2.c new file mode 100644 index 0000000..e69de29 diff --git a/DEV1.1S/TPREC/fibonacci.c b/DEV1.1S/TPREC/fibonacci.c new file mode 100644 index 0000000..92a5c43 --- /dev/null +++ b/DEV1.1S/TPREC/fibonacci.c @@ -0,0 +1,13 @@ +#include +#include + +int fib(int n) { + if (n > 1) return n + fib(n-1); + else if (n == 1) return 1; + else return 0; +} + +int main(void) { + fib(15); + return EXIT_SUCCESS; +} \ No newline at end of file diff --git a/DEV1.1S/TPREC/tableau.c b/DEV1.1S/TPREC/tableau.c new file mode 100644 index 0000000..ffe0bb4 --- /dev/null +++ b/DEV1.1S/TPREC/tableau.c @@ -0,0 +1,17 @@ +#include +#include + +void printTable(double* t, int n) { + if (n > 0) { + printf("%.5lf", *t); + if (n > 1) printf(", "); + printTable(t+1, n-1); + } else puts(""); +} + +int main(void) { + double t[5] = {1.72, 5.28, 9.025, 36.14, 3.14159}; + + printTable(t, 5); + return EXIT_SUCCESS; +} \ No newline at end of file diff --git a/DEV2.1/TP01/Bonjour.class b/DEV2.1/TP01/Bonjour.class new file mode 100644 index 0000000..12e2a1f Binary files /dev/null and b/DEV2.1/TP01/Bonjour.class differ diff --git a/DEV2.1/TP01/Bonjour.java b/DEV2.1/TP01/Bonjour.java new file mode 100644 index 0000000..fd1ccd8 --- /dev/null +++ b/DEV2.1/TP01/Bonjour.java @@ -0,0 +1,27 @@ +/** +* Cette classe est une simple coquille pour recevoir la méthode principale +* +* @version 1.1 09 March 2014 +* @author Luc Hernandez +*/ +public class Bonjour { + + /** + * Affiche «Bonjour !» + * + * @param args la liste des arguments de la ligne de commande (inutilisée ici) + */ + public static void main(String[] args) { + + int a = 12; + long b = 124L; + boolean c = true; + char d = 'E'; + float e = 1.2f; + double f = 38.12; + byte g = 0; + short h = 0; + System.out.println(a+" "+b+" "+c+" "+d+" "+e+" "+f+" "+g); + } + +} \ No newline at end of file diff --git a/DEV2.1/TP01/Grille.class b/DEV2.1/TP01/Grille.class new file mode 100644 index 0000000..548763c Binary files /dev/null and b/DEV2.1/TP01/Grille.class differ diff --git a/DEV2.1/TP01/Grille.java b/DEV2.1/TP01/Grille.java new file mode 100644 index 0000000..60c1b9c --- /dev/null +++ b/DEV2.1/TP01/Grille.java @@ -0,0 +1,10 @@ +public class Grille{ + public static void main(String[] args) { + System.out.println("+-+-+"); + int a = Integer.parseInt(args[0]); + for (int i=0; i< a; i++){ + System.out.println("| | |"); + System.out.println("+-+-+"); + } + } +} \ No newline at end of file diff --git a/DEV2.1/TP01/Somme.class b/DEV2.1/TP01/Somme.class new file mode 100644 index 0000000..adb35d4 Binary files /dev/null and b/DEV2.1/TP01/Somme.class differ diff --git a/DEV2.1/TP01/Somme.java b/DEV2.1/TP01/Somme.java new file mode 100644 index 0000000..08ca982 --- /dev/null +++ b/DEV2.1/TP01/Somme.java @@ -0,0 +1,10 @@ +public class Somme{ + public static void main(String[] args){ + int somme = 0; + for(String i : args){ + int nombre = Integer.parseInt(i); + somme+=nombre; + } + System.out.println(somme); + } +} \ No newline at end of file diff --git a/DEV2.1/TP01/exo2.class b/DEV2.1/TP01/exo2.class new file mode 100644 index 0000000..a9083e8 Binary files /dev/null and b/DEV2.1/TP01/exo2.class differ diff --git a/DEV2.1/TP01/exo2.java b/DEV2.1/TP01/exo2.java new file mode 100644 index 0000000..f6b65a4 --- /dev/null +++ b/DEV2.1/TP01/exo2.java @@ -0,0 +1,7 @@ +public class exo2{ + public static void main(String[] args) { + for(String i : args){ + System.out.println("Bonjour " + i); + } + } +} \ No newline at end of file diff --git a/DEV2.1/TP01/tri.class b/DEV2.1/TP01/tri.class new file mode 100644 index 0000000..c7477e7 Binary files /dev/null and b/DEV2.1/TP01/tri.class differ diff --git a/DEV2.1/TP01/tri.java b/DEV2.1/TP01/tri.java new file mode 100644 index 0000000..2d5713f --- /dev/null +++ b/DEV2.1/TP01/tri.java @@ -0,0 +1,14 @@ +import java.util.Arrays; +public class tri{ + public static void main(String[] args) { + int[] tab = new int[args.length]; + for(int i=0; i