This commit is contained in:
Simon SAYE BABU 2022-10-12 16:41:20 +02:00
parent 4d74cbe91b
commit 42f1cb7753
10 changed files with 280 additions and 0 deletions

22
DEV1.1/TP05/borne.c Normal file
View File

@ -0,0 +1,22 @@
#include <stdio.h>
#include <stdlib.h>
int main(void){
int x = 0;
int y = 0;
int i;
printf("Rentrer un entier: ");
scanf("%d",&x);
y = x;
while(x!=(-1)){
if(x<y){
y=x;
}
printf("Rentrer un entier sur lequel baser la table (-1 pour arretez): ");
scanf("%d",&x);
}
printf("%d",y);
return EXIT_SUCCESS;
}

17
DEV1.1/TP05/tables2.c Normal file
View File

@ -0,0 +1,17 @@
#include <stdio.h>
#include <stdlib.h>
int main(void){
int x = 0;
int i;
printf("Rentrer un entier sur lequel baser la table (-1 pour arretez): ");
scanf("%d",&x);
while(x!=(-1)){
for(i = 1;i<11;i++) {
printf("%d x %d = %d \n",x,i,x*i);
}
printf("Rentrer un entier sur lequel baser la table (-1 pour arretez): ");
scanf("%d",&x);
}
return EXIT_SUCCESS;
}

28
DEV1.1/TP06/compte.c Normal file
View File

@ -0,0 +1,28 @@
#include <stdio.h>
#include <stdlib.h>
int main(void){
char x;
int i = 0;
int j = 0;
int k = 0;
char y;
printf("Rentrer du texte:");
x = getchar();
while(1){
if(x == '\n'){
j++;
}
else{
if(x>='a'&&x<='z'&&x>='A'&&x<='Z'){
y=x;
}
}
x = getchar()
}
printf("saut a la ligne: %d \nnombre de charactere")
return EXIT_SUCCESS;
}

24
DEV1.1/TP06/disque.c Normal file
View File

@ -0,0 +1,24 @@
#include <stdio.h>
#include <stdlib.h>
int main(void){
int h = 0;
int x;
int y;
printf("Rentrer le rayon: ");
scanf("%d",&h);
for(x=-(h);x<h;x++){
for(y=-(h);y<h;y++){
if((x*x+y*y)<h*h){
printf("* ");
}
else{
printf(" ");
}
}
printf("\n");
}
return EXIT_SUCCESS;
}

27
DEV1.1/TP06/facteur.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("%d = ",x);
while(x!=0){
for(j = 2;j<x;j++) {
for(i = 1;i<j;i++)
if (i==1){printf("");}
else{
if ((j%i)==0) {
i=2*j;
}
}
}
if(i!=(2*j)&&(x%j==0)){
x=x/j;
printf("%d*",j);
}
}
return EXIT_SUCCESS;
}

26
DEV1.1/TP06/figures.c Normal file
View File

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

56
DEV1.1/TP06/maximum.c Normal file
View File

@ -0,0 +1,56 @@
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
int main(void){
srand(time(0));
int tab[10];
int i;
for(i=0;i<10;i++){
tab[i]=(rand()%(50+1-(-50)))-50;
}
int indice;
int max=tab[0];
for(i=1;i<10;i++){
if(max<tab[i]){
max = tab[i];
}
}
for(i=0;i<10;i++){
if(tab[i]==max){
indice=i;
}
}
for(i=0;i<=indice;i++){
if(i==indice){
printf(" |");
}
else{printf(" ");}
}
printf("\n");
for(i=0;i<=indice;i++){
if(i==indice){
printf(" v");
}
else{printf(" ");}
}
printf("\n+");
for(i=0;i<10;i++){
printf("-----+");
}
printf("\n");
for(i=0;i<10;i++){
printf("|%3d, ",tab[i]);
}
printf("|\n+");
for(i=0;i<10;i++){
printf("-----+");
}
printf("\n");
printf("le plus grand elmt est : %d \n", max);
return EXIT_SUCCESS;
}

26
DEV1.1/TP06/mirroir.c Normal file
View File

@ -0,0 +1,26 @@
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
int main(void){
srand(time(0));
int tab[10];
int i;
for(i=0;i<10;i++){
tab[i]=(rand()%(50+1-(-50)))-50;
}
for(i=0;i<10;i++){
printf("%d, ",tab[i]);
}
printf("\n");
int tabM[10];
for(i=0;i<10;i++){
tabM[i] = tab[9-i];
}
for(i=0;i<10;i++){
printf("%d, ",tabM[i]);
}
return EXIT_SUCCESS;
}

27
DEV1.1/TP06/recherche.c Normal file
View File

@ -0,0 +1,27 @@
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
int main(void){
srand(time(0));
int tab[10];
int i;
for(i=0;i<10;i++){
tab[i]=(rand()%(50+1-(-50)))-50;
}
for(i=0;i<10;i++){
printf("%d, ",tab[i]);
}
int look;
printf("\n Rentrez un nombre,\n si le nombre se trouve dans le tableau son indice sera affiché \n (le cas écheant -1 sera affiché):");
scanf("%d",&look);
int indice;
for(i=0;i<10;i++){
if(tab[i]==look){
indice=i;
}
}
printf("indice : %d \n", indice);
return EXIT_SUCCESS;
}

27
DEV1.1/TP06/remplissage.c Normal file
View File

@ -0,0 +1,27 @@
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
int main(void){
srand(time(0));
int tab[10];
int i;
for(i=0;i<10;i++){
tab[i]=(rand()%(50+1-(-50)))-50;
}
printf("+");
for(i=0;i<10;i++){
printf("-----+");
}
printf("\n");
for(i=0;i<10;i++){
printf("|%3d, ",tab[i]);
}
printf("|\n+");
for(i=0;i<10;i++){
printf("-----+");
}
printf("\n");
return EXIT_SUCCESS;
}