This commit is contained in:
Simon SAYE BABU 2022-10-04 17:30:38 +02:00
parent dbe90d10db
commit 4d74cbe91b
9 changed files with 230 additions and 0 deletions

31
DEV1.1/TP05/devinette.c Normal file
View File

@ -0,0 +1,31 @@
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
int main(void){
srand(time(0));
int x = (rand()%(100-0+1))+0;
int y = 0;
int i;
for(i=0;i<5;i++) {
printf("renter un chiffre entre 0 et 100:");
scanf("%d",&y);
if (y==x){
i=5;
printf("Bon nombre");
}
else{
if(y<x){
printf("+ \n");
}
else {
printf("- \n");
}
}
}
if (y!=x) {
printf("le bon nombre est %d",x);
}
return EXIT_SUCCESS;
}

19
DEV1.1/TP05/diviseur.c Normal file
View File

@ -0,0 +1,19 @@
#include <stdio.h>
#include <stdlib.h>
int main(void){
int x;
int y;
int temp;
printf("Rentrer deux entier: ");
scanf("%d %d",&x,&y);
while(y!=0){
temp=y;
y=x%y;
x=temp;
}
printf("%d",x);
return EXIT_SUCCESS;
}

18
DEV1.1/TP05/division.c Normal file
View File

@ -0,0 +1,18 @@
#include <stdio.h>
#include <stdlib.h>
int main(void){
int x = 0;
int y = 0;
int z = 0;
printf("Rentrer un entier >= 0: ");
scanf("%d",&x);
printf("Rentrer un entier > 0: ");
scanf("%d",&y);
while (x > y) {
z++;
x=x-y;
}
printf("%d = %d x %d + %d",((y*z)+x),y,z,x);
return EXIT_SUCCESS;
}

19
DEV1.1/TP05/fibbo.c Normal file
View File

@ -0,0 +1,19 @@
#include <stdio.h>
#include <stdlib.h>
int main(void){
int x = 0;
int i;
int y = 0;
int j = 1;
int temp;
printf("Rentrer un entier: ");
scanf("%d",&x);
for(i=1;i<=x;i++){
temp = y+j;
y=j;
j=temp;
}
printf("le %d terme de fibonacci est %d",x,y);
return EXIT_SUCCESS;
}

52
DEV1.1/TP05/figures.c Normal file
View File

@ -0,0 +1,52 @@
#include <stdio.h>
#include <stdlib.h>
int main(void){
char x;
int y;
int i;
int j;
int maxj=1;
printf("____________\n t) triangle\n c) Carre\nq) Quitter\nVotre choix ? :");
scanf("%c",&x);
if(x=='t'){
printf("Hauteur ?: ");
getchar();
scanf("%d",&y);
for(i=1;i<=y;i++){
for(j=1;j<=maxj;j++){
printf("*");
}
printf("\n");
maxj+=1;
}
}
else{
if(x=='c'){
printf("Hauteur ?: ");
getchar();
scanf("%d",&y);
for(i=1;i<=y;i++){
if((i==1)||(i==y)){
for(j=1;j<=y;j++){
printf("*");
}
}
else{
printf("*");
for(j=1;j<y-1;j++){
printf(" ");
}
printf("*");
}
printf("\n");
}
}
else{
if(x=='q'){
printf("Aurevoir...");
}
}
}
return EXIT_SUCCESS;
}

27
DEV1.1/TP05/grandetable.c Normal file
View File

@ -0,0 +1,27 @@
#include <stdio.h>
#include <stdlib.h>
int main(void){
int x = 0;
int i;
int j;
printf("Rentrer un entier: ");
scanf("%d",&x);
printf("X |");
for (i=0;i<x+1;i++){
printf("%5d",i);
}
printf("\n");
for (i=0;i<x;i++){
printf("------");
}
printf("\n");
for(i=0;i<x+1;i++) {
printf("%5d |",i);
for(j=0;j<x+1;j++) {
printf("%5d",i*j);
}
printf("\n");
}
return EXIT_SUCCESS;
}

24
DEV1.1/TP05/primarite.c Normal file
View File

@ -0,0 +1,24 @@
#include <stdio.h>
#include <stdlib.h>
int main(void){
int x = 0;
int i;
printf("Rentrer un entier: ");
scanf("%d",&x);
for(i = 1;i<x;i++) {
if (i==1){
printf("");
}
else {
if ((x%i)==0) {
printf("Pas premier");
i=2*x;
}
}
}
if(i!=(2*x)){
printf("Premier");
}
return EXIT_SUCCESS;
}

27
DEV1.1/TP05/sapin.c Normal file
View File

@ -0,0 +1,27 @@
#include <stdio.h>
#include <stdlib.h>
int main(void){
int x;
int i;
int j;
int maxj=1;
int maxj2=x/2-1;
printf("Hauteur ?: ");
scanf("%d",&x);
for(i=1;i<x;i++){
for(j=1;j<=x-i;j++){
printf(" ");
}
for(j=1;j<=maxj;j++){
printf("*");
}
printf("\n");
maxj+=2;
maxj2-=2;
}
return EXIT_SUCCESS;
}

13
DEV1.1/TP05/table.c Normal file
View File

@ -0,0 +1,13 @@
#include <stdio.h>
#include <stdlib.h>
int main(void){
int x = 0;
int i;
printf("Rentrer un entier: ");
scanf("%d",&x);
for(i = 1;i<11;i++) {
printf("%d x %d = %d \n",x,i,x*i);
}
return EXIT_SUCCESS;
}