4 Octobre
This commit is contained in:
parent
d4c676ea16
commit
8f64f6143a
26
DEV1.1/TP05:Boucles/Boucles:suite/Boucles:encore/figures.c
Normal file
26
DEV1.1/TP05:Boucles/Boucles:suite/Boucles:encore/figures.c
Normal file
@ -0,0 +1,26 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
int main() {
|
||||
char n;
|
||||
int h;
|
||||
int i;
|
||||
int j;
|
||||
int e;
|
||||
int z=0;
|
||||
while(z==0){
|
||||
printf("_______________\nt) Triangle\nc) Carre\nq) Quitter\nVotre choix ? ");
|
||||
scanf(" %c",&n);
|
||||
if (n=='t'){
|
||||
printf("Hauteur ? ");
|
||||
scanf("%d",&h);
|
||||
for (i=0;i<=h;i++){
|
||||
for (j=h-i;j>0;j--){
|
||||
} for (e=0;e<i;e++){
|
||||
printf("*");
|
||||
} printf("\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
19
DEV1.1/TP05:Boucles/Boucles:suite/Boucles:encore/sapin.c
Normal file
19
DEV1.1/TP05:Boucles/Boucles:suite/Boucles:encore/sapin.c
Normal file
@ -0,0 +1,19 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
int main() {
|
||||
int h;
|
||||
int i;
|
||||
int j;
|
||||
int e;
|
||||
printf("Hauteur ? ");
|
||||
scanf("%d",&h);
|
||||
for (i=0;i<=h;i++){
|
||||
for (j=h-i;j>0;j--){
|
||||
printf(" ");
|
||||
} for (e=0;e<(i*2)-1;e++){
|
||||
printf("*");
|
||||
} printf("\n");
|
||||
}
|
||||
return 0;
|
||||
}
|
33
DEV1.1/TP05:Boucles/Boucles:suite/devinette.c
Normal file
33
DEV1.1/TP05:Boucles/Boucles:suite/devinette.c
Normal file
@ -0,0 +1,33 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <time.h>
|
||||
int main() {
|
||||
int i;
|
||||
int n;
|
||||
int nt;
|
||||
const int max=100;
|
||||
const int tentmax=5;
|
||||
srand(time(NULL));
|
||||
i=rand();
|
||||
nt=0;
|
||||
while(i>100 || i<0){
|
||||
i=rand();
|
||||
}
|
||||
printf("Essayer de deviner le nombre, il est compris entre 0 et 100: ");
|
||||
for(nt=0;nt!=tentmax;nt++){
|
||||
scanf(" %d",&n);
|
||||
if (n==i){
|
||||
printf("Bravo, vous avez trouver le nombre qui etait %d.\n",i);
|
||||
break;
|
||||
} else{
|
||||
if(n>i){
|
||||
printf("C'est moins\n");
|
||||
} else{
|
||||
printf("C'est plus\n");
|
||||
}
|
||||
}
|
||||
} if (tentmax==nt){
|
||||
printf("Perdu, le nombre etait egal a %d.\n",i);
|
||||
}
|
||||
return 0;
|
||||
}
|
22
DEV1.1/TP05:Boucles/Boucles:suite/primarite.c
Normal file
22
DEV1.1/TP05:Boucles/Boucles:suite/primarite.c
Normal file
@ -0,0 +1,22 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
int main() {
|
||||
int n;
|
||||
int i;
|
||||
int p;
|
||||
printf("Veuillez saisir un entier naturel different de 0 et 1: ");
|
||||
scanf(" %d",&n);
|
||||
i=n;
|
||||
while (i>1){
|
||||
i--;
|
||||
if(n%i==0){
|
||||
printf("Ce nombre n'est pas un nombre premier.\n");
|
||||
p=1;
|
||||
break;
|
||||
}
|
||||
} if (p==0){
|
||||
printf("Ce nombre est un nombre premier.\n");
|
||||
}
|
||||
return 0;
|
||||
}
|
26
DEV1.1/TP05:Boucles/Boucles:suite/progression.c
Normal file
26
DEV1.1/TP05:Boucles/Boucles:suite/progression.c
Normal file
@ -0,0 +1,26 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
int main() {
|
||||
int x=0;
|
||||
int y=1;
|
||||
int z=1;
|
||||
int n;
|
||||
int i;
|
||||
printf("Quel numero de terme voulez vous: ");
|
||||
scanf("%d",&n);
|
||||
if (n==0){
|
||||
printf("Le terme 0 de le suite est %d",x);
|
||||
} else{
|
||||
if (i==1){
|
||||
printf("Le terme 1 de la suite est %d",y);
|
||||
} else{
|
||||
for (i=2;i<n;i++){
|
||||
x=y;
|
||||
y=z;
|
||||
z=x+y;
|
||||
} printf("Le terme %d de la suite est %d\n",n,z);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
28
DEV1.1/TP05:Boucles/Boucles:suite/table.c
Normal file
28
DEV1.1/TP05:Boucles/Boucles:suite/table.c
Normal file
@ -0,0 +1,28 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
int main() {
|
||||
int n;
|
||||
int i=0;
|
||||
int j;
|
||||
printf("Veuillez saisir la taille de la table: ");
|
||||
scanf("%d",&n);
|
||||
const int taille=n;
|
||||
printf(" X |");
|
||||
while(i<=taille){
|
||||
printf("%4d",i);
|
||||
i++;
|
||||
} printf("\n");
|
||||
i=0;
|
||||
while (i<=taille+1){
|
||||
i++;
|
||||
printf("----");
|
||||
} printf("\n");
|
||||
for (i=0;i<=taille;i++){
|
||||
printf("%3d |",i);
|
||||
for (j=0;j<=taille;j++){
|
||||
printf("%4d",i*j);
|
||||
} printf("\n");
|
||||
}
|
||||
return 0;
|
||||
}
|
20
DEV1.1/TP05:Boucles/sequence.c
Normal file
20
DEV1.1/TP05:Boucles/sequence.c
Normal file
@ -0,0 +1,20 @@
|
||||
#include <stdio.h>
|
||||
|
||||
int main() {
|
||||
int n;
|
||||
int m;
|
||||
int i;
|
||||
printf("Veuillez saisir 2 entiers separer d'un espace.\n");
|
||||
scanf("%d",&n);
|
||||
scanf(" %d",&m);
|
||||
if (n>m){
|
||||
for (i=m;i<=n;i++){
|
||||
printf("%d\n",i);
|
||||
}
|
||||
} else{
|
||||
for (i=n;i<=m;i++){
|
||||
printf("%d\n",i);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
Loading…
Reference in New Issue
Block a user