diff --git a/DEV1.1/adress.c b/DEV1.1/adress.c new file mode 100644 index 0000000..1dff85d --- /dev/null +++ b/DEV1.1/adress.c @@ -0,0 +1,52 @@ +#include +#include +#include + +/*#1) +int main(void){ + float a; + double b; + long double c; + char d; + short int e; + int f; + unsigned long int g; + + printf("%p\n", a); + printf("%p\n", b); + printf("%p\n", c); + printf("%p\n", d); + printf("%p\n", e); + printf("%p\n", f); + printf("%p\n", g); +}*/ + +/*#2) +int main(void){ + char min, maj; + char *p = NULL; + + for(min = 'a', maj = 'A'; maj <= 'Z'; min++, maj++) { + p = (p == &min) ? &maj : &min; + putchar(*p); + } + putchar('\n'); + return EXIT_SUCCESS; +}*/ + +int main(void){ + if(time(NULL)%2){ + int x = 59; + p = &x; + + } else { + int y = 31; + p = &y; + } + /* fragment inactif + printf("x=%d\n", x); + printf("y=%d\n", y); + */ + printf("%d\n", *p); + return EXIT_SUCCESS; +} diff --git a/DEV1.1/boucle_encore.c b/DEV1.1/boucle_encore.c index 210ad00..e7b8b44 100644 --- a/DEV1.1/boucle_encore.c +++ b/DEV1.1/boucle_encore.c @@ -29,16 +29,23 @@ }*/ int main(void){ - char triangle; + char choix; + int hauteur = 0; int i; int n = 0; int etoile; - printf("entrer votre choix: "); - scanf("%c", &triangle); + int coter; + int a; + int ecart; - if(triangle == 't'){ + + + printf("entrer votre choix: "); + scanf("%c", &choix); + + if(choix == 't'){ printf("entrer la hauteur du sapin: "); scanf("%d", &hauteur); @@ -48,9 +55,37 @@ int main(void){ printf("*"); } - n += 2; + n += 1; printf("\n"); } - } + }else if(choix == 'c'){ + printf("entrer la longueur du carre : "); + scanf("%d", &coter); + for(a = 0; a < coter; a++){ + printf("*"); + } + printf("\n"); + + for(a = 0; a < (coter - 2); a++){ + printf("*"); + for(ecart = 0; ecart < (coter - 2); ecart++){ + printf(" "); + } + printf("*"); + printf("\n"); + } + + for (a = 0; a < coter; a++){ + printf("*"); + } + printf("\n"); + + + }else if(choix == 'q'){ + return EXIT_SUCCESS; + }else{ + printf("caractère non reconues\n"); + + } } \ No newline at end of file diff --git a/DEV1.1/debogueur.c b/DEV1.1/debogueur.c new file mode 100755 index 0000000..8c13fce --- /dev/null +++ b/DEV1.1/debogueur.c @@ -0,0 +1,16 @@ +#include +#include + +int somme(int n, int m) { + return n+m; +} + +int main(void) { + int valeur; + int* p = NULL; + 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/fonction.c b/DEV1.1/fonction.c new file mode 100644 index 0000000..1b895e5 --- /dev/null +++ b/DEV1.1/fonction.c @@ -0,0 +1,46 @@ +#include +#include + +int triangle(int hauteur, int n =1, int i, int etoile){ + for (i = 0; i < hauteur; i++){ + + for(etoile = 0; etoile < n; etoile++){ + printf("*"); + } + + n += 2; + printf("\n"); + } +} + +int carre(int coter = 0, int ecart, int a, int etoile){ + + for (a = 0, a < coter, a++){ + pritnf("*"); + } + + for (a = 0, a < (coter - 2), a++){ + printf("*"); + + for(ecart = 0, ecart < (coter - 2), ecart++){ + pritnf(" "); + } + printf("*"); + } + for (a = 0, a < coter, a++){ + pritnf("*"); + } +} + +int menu(char choix){ + pritnf("triangle : t\ncarre : c\nquitter : q\nenter votre choix : "); + scanf("%c", &choix); + printf("\n"); + +} + +int main(void){ + + + +} \ No newline at end of file diff --git a/DEV1.1/tableau_multidimensionel.c b/DEV1.1/tableau_multidimensionel.c new file mode 100644 index 0000000..dcfa65a --- /dev/null +++ b/DEV1.1/tableau_multidimensionel.c @@ -0,0 +1,28 @@ +#include +#include + +int main(void){ + int t1 [2] [5] ={{1,2,3,4,5}, {1,2,3,4,5}}; + int t2 [3] [5] ={{1,2,3,4,5}, {6,7,8,9,10}, {11,12,13,14,15}}; + int t3 [5] [5] ={{0,0,0,0,0}, {1,0,0,0,0}, {1,2,0,0,0}, {1,2,3,0,0}, {1,2,3,4,0}}; + int i; + + for(i = 0; i < 10; i++){ + printf(" | "); + printf("%d", t1[i]); + } + printf("\n"); + + for(i = 0; i < 15; i++){ + printf(" | "); + printf("%d", t2[i]); + } + printf("\n"); + + for(i = 0; i < 25; i++){ + printf(" | "); + printf("%d", t3[i]); + } + printf("\n"); + +} \ No newline at end of file diff --git a/DEV1.1/tableaux.c b/DEV1.1/tableaux.c new file mode 100644 index 0000000..a6723e6 --- /dev/null +++ b/DEV1.1/tableaux.c @@ -0,0 +1,38 @@ +#include +#include +#include + +int main (void){ + int tableau[10]; + int i; + int x; + int a; + int plus_grand; + srand(time(NULL)); + + for (i = 0; i < 10; i++){ + tableau[i] = (rand() &101 ) -50 ; + + } + + for (x = 0; x < 10; x++){ + printf(" | "); + printf("%d", tableau[x]); + } + + printf("\n"); + + for (a = 0; a < 10; a++){ + if (tableau[a] > plus_grand){ + plus_grand = tableau[a]; + + } + + } + + printf("le plus grand est : "); + printf("%d", plus_grand); + printf("\n"); + + return EXIT_SUCCESS; +} \ No newline at end of file