From bf1a1e41b97ea99f0231a2081da7d61c2319f0c0 Mon Sep 17 00:00:00 2001 From: Simon Saye Babu Date: Tue, 15 Nov 2022 11:27:45 +0100 Subject: [PATCH] ennuie transcendental --- DEV1.1/TP06/mirroir.c | 3 +- DEV1.1/TP09/decoupage.c | 73 ++++++++++++++++++++++++++++++++++++++++ DEV1.1/TP09/echange.c | 10 ++++++ DEV1.1/TP09/mirroir.c | 37 ++++++++++++++++++++ DEV1.1/TP09/palindrome.c | 17 ++++++++++ DEV1.1/TP09/sigletons.c | 48 ++++++++++++++++++++++++++ DEV1.1/TP09/tp9.txt | 63 ++++++++++++++++++++++++++++++++++ DEV1.1/TP09/zero.c | 16 +++++++++ DEV1.1/TP10/binomial.c | 47 ++++++++++++++++++++++++++ DEV1.1/TP10/doubleur.c | 16 +++++++++ DEV1.1/TP10/envers.c | 20 +++++++++++ DEV1.1/TP10/tutoriel.c | 0 12 files changed, 349 insertions(+), 1 deletion(-) create mode 100644 DEV1.1/TP09/decoupage.c create mode 100644 DEV1.1/TP09/echange.c create mode 100644 DEV1.1/TP09/mirroir.c create mode 100644 DEV1.1/TP09/palindrome.c create mode 100644 DEV1.1/TP09/sigletons.c create mode 100644 DEV1.1/TP09/tp9.txt create mode 100644 DEV1.1/TP09/zero.c create mode 100644 DEV1.1/TP10/binomial.c create mode 100644 DEV1.1/TP10/doubleur.c create mode 100644 DEV1.1/TP10/envers.c create mode 100644 DEV1.1/TP10/tutoriel.c diff --git a/DEV1.1/TP06/mirroir.c b/DEV1.1/TP06/mirroir.c index 82d4c57..f9e42d4 100644 --- a/DEV1.1/TP06/mirroir.c +++ b/DEV1.1/TP06/mirroir.c @@ -1,6 +1,7 @@ #include #include #include + int main(void){ srand(time(0)); int tab[10]; @@ -23,4 +24,4 @@ int main(void){ } return EXIT_SUCCESS; -} \ No newline at end of file +} diff --git a/DEV1.1/TP09/decoupage.c b/DEV1.1/TP09/decoupage.c new file mode 100644 index 0000000..91b89a1 --- /dev/null +++ b/DEV1.1/TP09/decoupage.c @@ -0,0 +1,73 @@ +#include +#include + +int choix(){ + char x; + printf("____________\n t) triangle\n c) Carre\n q) Quitter\nVotre choix ? :"); + scanf("%c",&x); + if (x=='t') + { + return 1; + } + if (x=='c') + { + return 2; + } + if (x=='q') + { + return 0; + } +} + +void triangle(int hauteur){ + int maxj=1; + for(int i=1;i<=hauteur;i++){ + for(int j=1;j<=maxj;j++){ + printf("*"); + } + printf("\n"); + maxj+=1; + } +} + +void carre(int hauteur){ + for(int i=1;i<=hauteur;i++){ + if((i==1)||(i==hauteur)){ + for(int j=1;j<=hauteur;j++){ + printf("*"); + } + } + else{ + printf("*"); + for(int j=1;j +#include + + +void echange(int* a,int* b){ + int temp; + temp=*a; + *a=*b; + *b=temp; +} diff --git a/DEV1.1/TP09/mirroir.c b/DEV1.1/TP09/mirroir.c new file mode 100644 index 0000000..ca9d38b --- /dev/null +++ b/DEV1.1/TP09/mirroir.c @@ -0,0 +1,37 @@ +#include +#include +#include + +void afficher(int tab[]){ + for(int i=0;i<10;i++){ + printf("%d, ",tab[i]); + } + printf("\n"); +} + +void randomize(int tab[]){ + srand(time(0)); + for(int i=0;i<10;i++){ + tab[i]=(rand()%(50+1-(-50)))-50; + } +} + +void inverser(int tab[]){ + int tabM[10]; + for(int i=0;i<10;i++){ + tabM[i] = tab[9-i]; + } + for(int i=0;i<10;i++){ + tab[i] = tabM[i]; + } +} + +int main(int argc, char const *argv[]) +{ + int tab[10]; + randomize(tab); + afficher(tab); + inverser(tab); + afficher(tab); + return 0; +} \ No newline at end of file diff --git a/DEV1.1/TP09/palindrome.c b/DEV1.1/TP09/palindrome.c new file mode 100644 index 0000000..610faac --- /dev/null +++ b/DEV1.1/TP09/palindrome.c @@ -0,0 +1,17 @@ +#include +#include +#include + +int main(int argc, char const *argv[]){ + char* mot= (char*) malloc(100*sizeof(char)); + printf("rentrez un/des mot.s :\n"); + fgets(mot,100,stdin); + + for (int i = 0; i < 100*sizeof(char); ++i) + { + printf("%c",*(mot+i)); + } + + + return 0; +} \ No newline at end of file diff --git a/DEV1.1/TP09/sigletons.c b/DEV1.1/TP09/sigletons.c new file mode 100644 index 0000000..23894a2 --- /dev/null +++ b/DEV1.1/TP09/sigletons.c @@ -0,0 +1,48 @@ +#include +#include +#include + +int main(int argc, char const *argv[]){ + int x; + double temp; + printf("Combien de reel souhaitez vous rentrez ? : \n"); + scanf("%d",&x); + double listChiffre[x]; + for(int i=0;i +#include + + +void zero(double* a){ + *a=0.0; +} + +int main(void) +{ + double x=37.5; + printf("avant: %f\n",x ); + zero(&x); + printf("apres: %f\n",x ); + return 0; +} \ No newline at end of file diff --git a/DEV1.1/TP10/binomial.c b/DEV1.1/TP10/binomial.c new file mode 100644 index 0000000..93cd1e2 --- /dev/null +++ b/DEV1.1/TP10/binomial.c @@ -0,0 +1,47 @@ +/* fichier debogueur1.c : exemple a deboguer */ + +#include +#include + +/* fonction principale */ +int main(void) { + int i=-1, j=0, n, k, mem[100]; + + /* invite */ + printf("Calcul de C(n, k) :\n"); + + /* saisie de n */ + printf("Entrez n : "); + scanf("%d", &n); + while((n>100)||(n<1)) { + printf("n doit être compris entre 1 et 100 !\n"); + printf("Entrez n : "); + scanf("%d", &n); + } + + /* saisie de k */ + printf("Entrez k : "); + scanf("%d", &k); + while((k>n)||(k<1)) { + printf("k doit être compris entre 1 et %d !\n", n); + printf("Entrez k : "); + scanf("%d", &k); + } + + /* calculs... */ + while (i +#include + +int somme(int n, int m) { + return n+m; +} + +int main(void) { + int valeur; + int* p = (int*) malloc(2*sizeof(int)); + printf("Entrez un entier : "); + scanf("%d", p); + + printf("Le double vaut %d\n", somme(*p, *p)); + return EXIT_SUCCESS; +} \ No newline at end of file diff --git a/DEV1.1/TP10/envers.c b/DEV1.1/TP10/envers.c new file mode 100644 index 0000000..2ea0406 --- /dev/null +++ b/DEV1.1/TP10/envers.c @@ -0,0 +1,20 @@ +#include +#include +#include + +void envers(const char texte[]) { + unsigned position; + for(position = strlen(texte)-1; position != 4294967295; position--) { + printf("%c", texte[position]); + } + printf("\n"); +} + +int main(int argc, char** argv) { + if (argc < 2) { + printf("usage : %s \n", argv[0]); + return EXIT_FAILURE; + } + envers(argv[1]); + return EXIT_SUCCESS; +} \ No newline at end of file diff --git a/DEV1.1/TP10/tutoriel.c b/DEV1.1/TP10/tutoriel.c new file mode 100644 index 0000000..e69de29