update
This commit is contained in:
BIN
DEV/DEV1.1/TP_Boucles2/exe
Executable file
BIN
DEV/DEV1.1/TP_Boucles2/exe
Executable file
Binary file not shown.
29
DEV/DEV1.1/TP_Boucles2/q1.c
Normal file
29
DEV/DEV1.1/TP_Boucles2/q1.c
Normal file
@@ -0,0 +1,29 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <time.h>
|
||||
|
||||
int main(void) {
|
||||
int nombreMystere;
|
||||
int chiffreSaisis;
|
||||
int i;
|
||||
srand(time(NULL));
|
||||
nombreMystere =(rand()%100)+1;
|
||||
for (i=0;i<5;i+=1){
|
||||
printf("Deviner mon nombre : ");
|
||||
scanf("%d", &chiffreSaisis);
|
||||
if (chiffreSaisis > nombreMystere){
|
||||
printf("C'est moins !\n");
|
||||
}
|
||||
if (chiffreSaisis < nombreMystere){
|
||||
printf("C'est plus !\n");
|
||||
}
|
||||
if (chiffreSaisis == nombreMystere){
|
||||
printf("Bravo !!! c'était bien ");
|
||||
printf("%d", nombreMystere);
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
}
|
||||
printf("Perdu ! vos 5 tentatives n'ont pas suffit à trouver que j'avais choisis ");
|
||||
printf("%d\n", nombreMystere);
|
||||
return EXIT_SUCCESS;
|
||||
}
|
0
DEV/DEV1.1/TP_Boucles2/q1.c~
Normal file
0
DEV/DEV1.1/TP_Boucles2/q1.c~
Normal file
21
DEV/DEV1.1/TP_Boucles2/q2.c
Normal file
21
DEV/DEV1.1/TP_Boucles2/q2.c
Normal file
@@ -0,0 +1,21 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
int main(void) {
|
||||
int chiffreSaisis;
|
||||
int diviseur;
|
||||
printf("Saisissez un entier : ");
|
||||
scanf("%d", &chiffreSaisis);
|
||||
for(diviseur=chiffreSaisis-1;diviseur>1;diviseur-=1){
|
||||
if (chiffreSaisis%diviseur==0){
|
||||
printf("Ce nombre n'est pas premier\n");
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
}
|
||||
if (chiffreSaisis==1){
|
||||
printf("Ce nombre n'est pas premier\n");
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
printf("Ce nombre est premier\n");
|
||||
return EXIT_SUCCESS;
|
||||
}
|
0
DEV/DEV1.1/TP_Boucles2/q2.c~
Normal file
0
DEV/DEV1.1/TP_Boucles2/q2.c~
Normal file
40
DEV/DEV1.1/TP_Boucles2/q3.c
Normal file
40
DEV/DEV1.1/TP_Boucles2/q3.c
Normal file
@@ -0,0 +1,40 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
int main(void) {
|
||||
int taille;
|
||||
int x;
|
||||
printf("Saisissez la taille de la table de multiplication que vous souhaitez : ");
|
||||
scanf("%d", &taille);
|
||||
for (x=-2; x<=taille; x+=1){
|
||||
int y;
|
||||
printf("\n");
|
||||
for (y=-2; y<=taille; y+=1){
|
||||
if (x==-2){
|
||||
if (y==-2){
|
||||
printf(" X ");}
|
||||
if (y==-1){
|
||||
printf(" | ");}
|
||||
if (y>=0){
|
||||
printf("%3d", y);}
|
||||
}
|
||||
if (x==-1){
|
||||
if (y==-2){
|
||||
printf("---");}
|
||||
if (y==-1){
|
||||
printf("-+-");}
|
||||
if (y>=0){
|
||||
printf("---");}
|
||||
}
|
||||
if (x >= 0){
|
||||
if (y==-2){
|
||||
printf("%3d",x);}
|
||||
if (y==-1){
|
||||
printf(" | ");}
|
||||
if (y>=0){
|
||||
printf("%3d",x*y);}
|
||||
}
|
||||
}
|
||||
}
|
||||
return EXIT_SUCCESS;
|
||||
}
|
0
DEV/DEV1.1/TP_Boucles2/q3.c~
Normal file
0
DEV/DEV1.1/TP_Boucles2/q3.c~
Normal file
26
DEV/DEV1.1/TP_Boucles2/q4.c
Normal file
26
DEV/DEV1.1/TP_Boucles2/q4.c
Normal file
@@ -0,0 +1,26 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
int main(void) {
|
||||
int i;
|
||||
int n0=0;
|
||||
int n1=1;
|
||||
int n;
|
||||
printf("Saisissez un entier : ");
|
||||
scanf("%d", &n);
|
||||
for(i=0;i<n;i+=1){
|
||||
if (i%2==0){
|
||||
n0=n0+n1;
|
||||
} else{
|
||||
n1=n0+n1;
|
||||
}
|
||||
}
|
||||
if (n%2==0) {
|
||||
printf("%d\n",n0);
|
||||
} else{
|
||||
printf("%d\n",n1);
|
||||
}
|
||||
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
0
DEV/DEV1.1/TP_Boucles2/q4.c~
Normal file
0
DEV/DEV1.1/TP_Boucles2/q4.c~
Normal file
26
DEV/DEV1.1/TP_Boucles2/q5.c
Normal file
26
DEV/DEV1.1/TP_Boucles2/q5.c
Normal file
@@ -0,0 +1,26 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
int main(void) {
|
||||
int i;
|
||||
int n0=0;
|
||||
int n1=1;
|
||||
int n;
|
||||
printf("Saisissez un entier : ");
|
||||
scanf("%d", &n);
|
||||
for(i=0;i<n;i+=1){
|
||||
if (i%2==0){
|
||||
n0=n0+n1;
|
||||
} else{
|
||||
n1=n0+n1;
|
||||
}
|
||||
}
|
||||
if (n%2==0) {
|
||||
printf("%d\n",n0);
|
||||
} else{
|
||||
printf("%d\n",n1);
|
||||
}
|
||||
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
Reference in New Issue
Block a user