diff --git a/DEV1.1/TP15/miroir b/DEV1.1/TP15/miroir new file mode 100755 index 0000000..fc95b9a Binary files /dev/null and b/DEV1.1/TP15/miroir differ diff --git a/DEV1.1/TP15/miroir.c b/DEV1.1/TP15/miroir.c index 82462ef..52ee576 100644 --- a/DEV1.1/TP15/miroir.c +++ b/DEV1.1/TP15/miroir.c @@ -4,19 +4,23 @@ int remplissage( int tab[10]){ int tour,signe; + int tab_temp[2]; srand(time(NULL)); for (tour=0;tour<10;tour++){ tab[tour]=rand()%51; - int tab_temp[2]={tab[tour],tab[tour]*(-1)}; + tab_temp[0]=tab[tour]; + tab_temp[1]=tab[tour]*(-1); signe=rand()%2; tab[tour]=tab_temp[signe]; } + return *tab; } int inversion(const int tab[10], int tab_inv[10]){ int tour; for (tour=0;tour<10;tour++) - tab_val[tour]=tab[(9-tour)]; + tab_inv[tour]=tab[(9-tour)]; + return *tab_inv; } void affichage( int tab[10]){ @@ -33,11 +37,12 @@ void affichage( int tab[10]){ for (tour=0;tour<10;tour++) printf("-----+"); printf("\n"); +} int main(void) { int tab[10]; - remplissage(tab); int tab_inv[10]; + remplissage(tab); inversion(tab,tab_inv); affichage(tab); printf("\n"); diff --git a/DEV1.1/TP15/zero b/DEV1.1/TP15/zero new file mode 100755 index 0000000..fb25d04 Binary files /dev/null and b/DEV1.1/TP15/zero differ diff --git a/DEV1.1/TP15/zero.c b/DEV1.1/TP15/zero.c new file mode 100644 index 0000000..063fed1 --- /dev/null +++ b/DEV1.1/TP15/zero.c @@ -0,0 +1,18 @@ +#include +#include + +int zero(double a) { + a = 0.0; + return a; +} + +int main(void) { + double x=37.5; + printf("avant : %f\n", x); + x=zero(x); + printf("après : %f\n", x); + return EXIT_SUCCESS; +} + +/*Elle ne fait pas son travaille car la fonction ne renvoie +rien et que la valeur 0 n'est pas atribuées*/ \ No newline at end of file diff --git a/DEV1.1/TP16/binomial b/DEV1.1/TP16/binomial new file mode 100755 index 0000000..3b467fd Binary files /dev/null and b/DEV1.1/TP16/binomial differ diff --git a/DEV1.1/TP16/binomial.c b/DEV1.1/TP16/binomial.c new file mode 100644 index 0000000..5619019 --- /dev/null +++ b/DEV1.1/TP16/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 main(void) { + int a = 1, b = 2, c = 3; + int *p, *q; + + p=&a; + q=&c; + *p=(*q)++; + p=q; + q=&b; + *p-=*q; + ++*q; + *p*=*q; + a=++*q**p; + p=&a; + *q=*p/(*q); + return EXIT_SUCCESS; +} \ No newline at end of file diff --git a/DEV1.1/TP16/tutoriel b/DEV1.1/TP16/tutoriel new file mode 100755 index 0000000..963a8d0 Binary files /dev/null and b/DEV1.1/TP16/tutoriel differ diff --git a/DEV1.1/TP16/tutoriel.c b/DEV1.1/TP16/tutoriel.c new file mode 100644 index 0000000..106baac --- /dev/null +++ b/DEV1.1/TP16/tutoriel.c @@ -0,0 +1,16 @@ +#include +#include + +int somme(int n, int m) { + return n+m; +} + +int main(void) { + int valeur; + int* p = &valeur; + 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/TP16/tutoriel2 b/DEV1.1/TP16/tutoriel2 new file mode 100755 index 0000000..2dc26cf Binary files /dev/null and b/DEV1.1/TP16/tutoriel2 differ diff --git a/DEV1.1/TP16/tutoriel2.c b/DEV1.1/TP16/tutoriel2.c new file mode 100644 index 0000000..1a62e80 --- /dev/null +++ b/DEV1.1/TP16/tutoriel2.c @@ -0,0 +1,20 @@ +#include +#include +#include + +void envers(const char texte[]) { + int position; + for(position = strlen(texte)-1; position >= 0; 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