diff --git a/DEV1.1/TP05/inte b/DEV1.1/TP05/inte new file mode 100755 index 0000000..b3e81f6 Binary files /dev/null and b/DEV1.1/TP05/inte differ diff --git a/DEV1.1/TP05/inte.c b/DEV1.1/TP05/inte.c new file mode 100644 index 0000000..e3147c9 --- /dev/null +++ b/DEV1.1/TP05/inte.c @@ -0,0 +1,17 @@ +#include +#include + +int main(void) { + double capital; + int annee; + + printf("Montant a investir : "); + scanf("%lf", &capital); + + for (annee = 1; annee <= 7; annee++) { + capital = capital * 1.04; + printf("Annee %d : %.2f €\n", annee, capital); + } + + return 0; +} diff --git a/DEV1.1/TP06/bille b/DEV1.1/TP06/bille new file mode 100755 index 0000000..ad68f61 Binary files /dev/null and b/DEV1.1/TP06/bille differ diff --git a/DEV1.1/TP06/bille.c b/DEV1.1/TP06/bille.c new file mode 100644 index 0000000..0ec7dfd --- /dev/null +++ b/DEV1.1/TP06/bille.c @@ -0,0 +1,24 @@ +#include +#include + +int main(void) { + int x=3; + + if (x=2) { + printf("x vaut 2\n"); + } else { + printf("x est different de 2\n"); + } + + printf("%d\n", x); + + if (x=0) { + printf("x vaut 0\n"); + } else { + printf("x est different de 0\n"); + } + + printf("%d\n", x); + + return EXIT_SUCCESS; +} \ No newline at end of file diff --git a/DEV1.1/TP06/biss.c b/DEV1.1/TP06/biss.c new file mode 100644 index 0000000..42713b0 --- /dev/null +++ b/DEV1.1/TP06/biss.c @@ -0,0 +1,9 @@ +#include +#include + +int main(void) { + int annee; + + printf("Veuillez entrer l'année actuelle : \n"); + z +} \ No newline at end of file diff --git a/DEV1.1/TP06/produit b/DEV1.1/TP06/produit new file mode 100755 index 0000000..2dcb658 Binary files /dev/null and b/DEV1.1/TP06/produit differ diff --git a/DEV1.1/TP06/produit.c b/DEV1.1/TP06/produit.c new file mode 100644 index 0000000..904c6d6 --- /dev/null +++ b/DEV1.1/TP06/produit.c @@ -0,0 +1,22 @@ +#include +#include + +int main(void) { + int n, m, o; + int temp; + + printf("Veuillez entrer une première valeur entière : "); + scanf("%i", &n); + printf("Veuillez entrer une deuxième valeur entière : "); + scanf("%i", &m); + printf("Veuillez entrer une troisième valeur entière : "); + scanf("%i", &o); + + if (n > m) { temp = n; n = m; m = temp; } + if (n > o) { temp = n; n = o; o = temp; } + if (m > o) { temp = m; m = o; o = temp; } + + printf("Les valeurs dans l'ordre croissant sont : %i < %i < %i\n", n, m, o); + + return 0; +} diff --git a/DEV1.1/TP06/triple b/DEV1.1/TP06/triple new file mode 100755 index 0000000..a6fee4d Binary files /dev/null and b/DEV1.1/TP06/triple differ diff --git a/DEV1.1/TP06/triple.c b/DEV1.1/TP06/triple.c new file mode 100644 index 0000000..8067372 --- /dev/null +++ b/DEV1.1/TP06/triple.c @@ -0,0 +1,13 @@ +#include +#include + +int main(void) { + int n; + + printf("Veuillez entrer un entier naturel : \n"); + scanf("%i", &n); + int reste = n % 3; + int plus_proche = (reste == 0) ? n : (reste == 1) ? n - 1 : n + 1; + printf("%i\n", plus_proche); + return EXIT_SUCCESS; +} diff --git a/DEV1.1/TP07/Table.c b/DEV1.1/TP07/Table.c new file mode 100644 index 0000000..518dd34 --- /dev/null +++ b/DEV1.1/TP07/Table.c @@ -0,0 +1,16 @@ +#include +#include + +int main(void) { + int n; + int i; + + printf("entrez un entier : "); + scanf("%d", &n); + + for (i = 1; i <= 10; i++) { + printf("%3d x %2d = %4d\n", n, i, n * i); + } + + return EXIT_SUCCESS; +} \ No newline at end of file diff --git a/DEV1.1/TP07/div.c b/DEV1.1/TP07/div.c new file mode 100644 index 0000000..039df3e --- /dev/null +++ b/DEV1.1/TP07/div.c @@ -0,0 +1,27 @@ +#include +#include + +int main(void) { + int dividende; + int diviseur; + int quotient; + int reste; + + printf("Entrez une valeur >= 0 : "); + scanf("%d", ÷nde); + + printf("Entrez une valeur > 0 : "); + scanf("%d", &diviseur); + + quotient = 0; + reste = dividende; + + while (reste >= diviseur) { + reste = reste - diviseur; + quotient++; + } + + printf("--> %d = %d x %d + %d\n", dividende, quotient, diviseur, reste); + + return EXIT_SUCCESS; +} \ No newline at end of file diff --git a/DEV1.1/TP07/filtrage b/DEV1.1/TP07/filtrage new file mode 100755 index 0000000..34fce5d Binary files /dev/null and b/DEV1.1/TP07/filtrage differ diff --git a/DEV1.1/TP07/filtrage.c b/DEV1.1/TP07/filtrage.c new file mode 100644 index 0000000..2331956 --- /dev/null +++ b/DEV1.1/TP07/filtrage.c @@ -0,0 +1,19 @@ +#include +#include + +int main(void) { + double capital; + int annee; + + do { + printf("Montant a investir (entre 1000 et 50000) : "); + scanf("%lf", &capital); + } while (capital < 1000.0 || capital > 50000.0); + + for (annee = 1; annee <= 7; annee++) { + capital = capital * 1.04; + printf("Annee %d : %.2f €\n", annee, capital); + } + + return EXIT_SUCCESS; +} \ No newline at end of file diff --git a/DEV1.1/TP07/sequence b/DEV1.1/TP07/sequence new file mode 100755 index 0000000..5e46371 Binary files /dev/null and b/DEV1.1/TP07/sequence differ diff --git a/DEV1.1/TP07/sequence.c b/DEV1.1/TP07/sequence.c new file mode 100644 index 0000000..64e53c9 --- /dev/null +++ b/DEV1.1/TP07/sequence.c @@ -0,0 +1,27 @@ +#include +#include + +int main(void) { + int a; + int b; + int min; + int max; + int i; + + printf("Entrez deux entiers : "); + scanf("%d %d", &a, &b); + + if (a < b) { + min = a; + max = b; + } else { + min = b; + max = a; + } + + for (i = min; i <= max; i++) { + printf("%d\n", i); + } + + return EXIT_SUCCESS; +} diff --git a/DEV1.1/TP07/sequence1 b/DEV1.1/TP07/sequence1 new file mode 100755 index 0000000..1c3b5a6 Binary files /dev/null and b/DEV1.1/TP07/sequence1 differ diff --git a/DEV1.1/TP07/sequence1.c b/DEV1.1/TP07/sequence1.c new file mode 100644 index 0000000..a52e6d9 --- /dev/null +++ b/DEV1.1/TP07/sequence1.c @@ -0,0 +1,29 @@ +#include +#include + +int main(void) { + int a; + int b; + int min; + int max; + int i; + + printf("Entrez deux entiers : "); + scanf("%d %d", &a, &b); + + if (a < b) { + min = a; + max = b; + } else { + min = b; + max = a; + } + + i = min; + while (i <= max) { + printf("%d\n", i); + i++; + } + + return EXIT_SUCCESS; +} diff --git a/DEV1.1/TP07/sequence2 b/DEV1.1/TP07/sequence2 new file mode 100755 index 0000000..eff8d78 Binary files /dev/null and b/DEV1.1/TP07/sequence2 differ diff --git a/DEV1.1/TP07/sequence2.c b/DEV1.1/TP07/sequence2.c new file mode 100644 index 0000000..c0bc16c --- /dev/null +++ b/DEV1.1/TP07/sequence2.c @@ -0,0 +1,29 @@ +#include +#include + +int main(void) { + int a; + int b; + int min; + int max; + int i; + + printf("Entrez deux entiers : "); + scanf("%d %d", &a, &b); + + if (a < b) { + min = a; + max = b; + } else { + min = b; + max = a; + } + + i = min; + do { + printf("%d\n", i); + i++; + } while (i <= max); + + return EXIT_SUCCESS; +} \ No newline at end of file diff --git a/DEV1.1/TP07/table b/DEV1.1/TP07/table new file mode 100755 index 0000000..94ab321 Binary files /dev/null and b/DEV1.1/TP07/table differ diff --git a/DEV1.1/TP08/devi b/DEV1.1/TP08/devi new file mode 100755 index 0000000..dbab78a Binary files /dev/null and b/DEV1.1/TP08/devi differ diff --git a/DEV1.1/TP08/devi.c b/DEV1.1/TP08/devi.c new file mode 100644 index 0000000..31b3b7a --- /dev/null +++ b/DEV1.1/TP08/devi.c @@ -0,0 +1,36 @@ +#include +#include +#include + +int main(void) { + int secret; + int proposition; + int tentative; + int trouve; + + srand((unsigned int)time(NULL)); + secret = rand() % 101; + + trouve = 0; + + for (tentative = 1; tentative <= 5 && !trouve; tentative++) { + printf("Tentative %d/5 (entre 0 et 100) : ", tentative); + scanf("%d", &proposition); + + if (proposition < secret) { + printf("+\n"); + } else if (proposition > secret) { + printf("-\n"); + } else { + trouve = 1; + } + } + + if (trouve) { + printf("Gagne !\n"); + } else { + printf("Perdu ! Le nombre etait %d.\n", secret); + } + + return EXIT_SUCCESS; +} \ No newline at end of file diff --git a/DEV1.1/TP08/prem b/DEV1.1/TP08/prem new file mode 100755 index 0000000..ce3506c Binary files /dev/null and b/DEV1.1/TP08/prem differ diff --git a/DEV1.1/TP08/prem.c b/DEV1.1/TP08/prem.c new file mode 100644 index 0000000..60e24ef --- /dev/null +++ b/DEV1.1/TP08/prem.c @@ -0,0 +1,31 @@ +#include +#include + +int main(void) { + int n; + int i; + int est_premier; + + printf("Entrez un entier naturel : "); + scanf("%d", &n); + + if (n < 2) { + est_premier = 0; + } else { + est_premier = 1; + for (i = 2; i * i <= n; i++) { + if (n % i == 0) { + est_premier = 0; + i = n; + } + } + } + + if (est_premier) { + printf("%d est un nombre premier.\n", n); + } else { + printf("%d n'est pas un nombre premier.\n", n); + } + + return EXIT_SUCCESS; +} diff --git a/DEV1.1/TP10/aff.c b/DEV1.1/TP10/aff.c new file mode 100644 index 0000000..fcbc0f5 --- /dev/null +++ b/DEV1.1/TP10/aff.c @@ -0,0 +1,30 @@ +#include +#include + +int main(void) { + int v_lundi, v_mardi, v_mercredi, v_jeudi, v_vendredi; + int total; + double moyenne; + + printf("Visiteurs lundi : "); + scanf("%d", &v_lundi); + + printf("Visiteurs mardi : "); + scanf("%d", &v_mardi); + + printf("Visiteurs mercredi : "); + scanf("%d", &v_mercredi); + + printf("Visiteurs jeudi : "); + scanf("%d", &v_jeudi); + + printf("Visiteurs vendredi : "); + scanf("%d", &v_vendredi); + + total = v_lundi + v_mardi + v_mercredi + v_jeudi + v_vendredi; + moyenne = (double)total / 5; + + printf("Nombre moyen de visiteurs par jour : %.2f\n", moyenne); + + return EXIT_SUCCESS; +} diff --git a/DEV1.1/TP10/deb b/DEV1.1/TP10/deb new file mode 100755 index 0000000..808d6ea Binary files /dev/null and b/DEV1.1/TP10/deb differ diff --git a/DEV1.1/TP10/deb.c b/DEV1.1/TP10/deb.c new file mode 100644 index 0000000..7a154f5 --- /dev/null +++ b/DEV1.1/TP10/deb.c @@ -0,0 +1,17 @@ +#include +#include + +int main(void) { + int valeur_int; + char valeur_char; + + printf("Entrez un entier : "); + scanf("%d", &valeur_int); + + valeur_char = (char)valeur_int; + + printf("Valeur dans int : %d\n", valeur_int); + printf("Valeur dans char : %d (caractere : '%c')\n", valeur_char, valeur_char); + + return EXIT_SUCCESS; +} \ No newline at end of file diff --git a/DEV1.1/TP01/a.out b/DEV1.1/TP10/var similarity index 77% rename from DEV1.1/TP01/a.out rename to DEV1.1/TP10/var index 50541d7..de47669 100755 Binary files a/DEV1.1/TP01/a.out and b/DEV1.1/TP10/var differ diff --git a/DEV1.1/TP10/var.c b/DEV1.1/TP10/var.c new file mode 100644 index 0000000..dfe262c --- /dev/null +++ b/DEV1.1/TP10/var.c @@ -0,0 +1,18 @@ +#include +#include + +int main(void) { + printf("signed char : %hhd\n", 77); + printf("unsigned char : %hhu\n", 77); + printf("short int : %hd\n", 77); + printf("unsigned short int : %hu\n", 77); + printf("int : %d\n", 77); + printf("unsigned int : %u\n", 77U); + printf("long int : %ld\n", 77L); + printf("unsigned long int : %lu\n", 77UL); + printf("float : %.0f\n", 77.0f); + printf("double : %.0f\n", 77.0); + printf("long double : %.0Lf\n", 77.0L); + + return EXIT_SUCCESS; +} \ No newline at end of file diff --git a/DEV1.1/TP01/salut b/DEV1.1/TP13/a.out similarity index 67% rename from DEV1.1/TP01/salut rename to DEV1.1/TP13/a.out index 50541d7..e451f11 100755 Binary files a/DEV1.1/TP01/salut and b/DEV1.1/TP13/a.out differ diff --git a/DEV1.1/TP13/horiz b/DEV1.1/TP13/horiz new file mode 100755 index 0000000..7a15523 Binary files /dev/null and b/DEV1.1/TP13/horiz differ diff --git a/DEV1.1/TP13/horiz.c b/DEV1.1/TP13/horiz.c new file mode 100644 index 0000000..4472e04 --- /dev/null +++ b/DEV1.1/TP13/horiz.c @@ -0,0 +1,64 @@ +#include +#include + +int main(void) { + int t1[2][5]; + int t2[3][5]; + int t3[5][5]; + int i; + int j; + + for (i = 0; i < 2; i++) { + for (j = 0; j < 5; j++) { + t1[i][j] = j + 1; + } + } + + for (i = 0; i < 3; i++) { + for (j = 0; j < 5; j++) { + t2[i][j] = i * 5 + j + 1; + } + } + + for (i = 0; i < 5; i++) { + for (j = 0; j < 5; j++) { + if (j < i) { + t3[i][j] = j + 1; + } else { + t3[i][j] = 0; + } + } + } + +/*Affichage*/ + + for (i = 0; i < 5; i++) { + if (i < 2) { + for (j = 0; j < 5; j++) { + printf("%2d ", t1[i][j]); + } + } else { + printf(" "); + } + + printf(" "); + + if (i < 3) { + for (j = 0; j < 5; j++) { + printf("%2d ", t2[i][j]); + } + } else { + printf(" "); + } + + printf(" "); + + for (j = 0; j < 5; j++) { + printf("%2d ", t3[i][j]); + } + + printf("\n"); + } + + return 0; +} \ No newline at end of file diff --git a/DEV1.1/TP13/prog b/DEV1.1/TP13/prog new file mode 100755 index 0000000..caaa682 Binary files /dev/null and b/DEV1.1/TP13/prog differ diff --git a/DEV1.1/TP13/prog.c b/DEV1.1/TP13/prog.c new file mode 100644 index 0000000..a2ade0f --- /dev/null +++ b/DEV1.1/TP13/prog.c @@ -0,0 +1,92 @@ +#include +#include + +int main(void) { + int t1[2][5]; + int t2[3][5]; + int t3[5][5]; + int i; + int j; + + /*Remplissage tableaux*/ + + for (i = 0; i < 2; i++) { + for (j = 0; j < 5; j++) { + t1[i][j] = j + 1; + } + } + + for (i = 0; i < 3; i++) { + for (j = 0; j < 5; j++) { + t2[i][j] = i * 5 + j + 1; + } + } + + for (i = 0; i < 5; i++) { + for (j = 0; j < 5; j++) { + if (j < i) { + t3[i][j] = j + 1; + } else { + t3[i][j] = 0; + } + } + } + + /*Affichage Normal*/ + + printf("\n Affichage normal \n"); + + printf("Tableau t1 :\n"); + for (i = 0; i < 2; i++) { + for (j = 0; j < 5; j++) { + printf("%2d ", t1[i][j]); + } + printf("\n"); + } + + printf("\nTableau t2 :\n"); + for (i = 0; i < 3; i++) { + for (j = 0; j < 5; j++) { + printf("%2d ", t2[i][j]); + } + printf("\n"); + } + + printf("\nTableau t3 :\n"); + for (i = 0; i < 5; i++) { + for (j = 0; j < 5; j++) { + printf("%2d ", t3[i][j]); + } + printf("\n"); + } + + /*Inversion ligne-colonne*/ + + printf("\n Inversion ligne-colonne \n"); + + printf("Tableau t1 inverse :\n"); + for (j = 0; j < 5; j++) { + for (i = 0; i < 2; i++) { + printf("%2d ", t1[i][j]); + } + printf("\n"); + } + + printf("\nTableau t2 inverse :\n"); + for (j = 0; j < 5; j++) { + for (i = 0; i < 3; i++) { + printf("%2d ", t2[i][j]); + } + printf("\n"); + } + + printf("\nTableau t3 inverse :\n"); + for (j = 0; j < 5; j++) { + for (i = 0; i < 5; i++) { + printf("%2d ", t3[i][j]); + } + printf("\n"); + } + + return 0; +} \ No newline at end of file diff --git a/DEV1.1/TP14/cart b/DEV1.1/TP14/cart new file mode 100755 index 0000000..5d6f5a7 Binary files /dev/null and b/DEV1.1/TP14/cart differ diff --git a/DEV1.1/TP01/salut.c b/DEV1.1/TP14/cart.c similarity index 55% rename from DEV1.1/TP01/salut.c rename to DEV1.1/TP14/cart.c index 0d8c4f4..e6b8bb9 100644 --- a/DEV1.1/TP01/salut.c +++ b/DEV1.1/TP14/cart.c @@ -1,10 +1,11 @@ -/* premier programme */ - -#include #include +#include int main(void) { - printf("Hello World!\n"); + double x; + double* ptr; + + ptr = &x; + printf("%p\n", ptr); return EXIT_SUCCESS; -} - +} \ No newline at end of file