Mise à jour du git

This commit is contained in:
Vieira
2021-11-30 15:07:19 +01:00
parent 15349adb76
commit 1225df614e
121 changed files with 345 additions and 1 deletions

View File

@@ -0,0 +1,87 @@
#include <stdio.h>
#include <stdlib.h>
int choice;
int x;
int menu()
{
printf("--------------\n");
printf(" 1) Triangle\n");
printf(" 2) Carré\n");
printf(" 3) Quitter\n");
printf("Votre choix ?");
scanf("%d", &choice);
return choice;
}
int carree()
{
int c,h,cpt,cpt2;
c=0;
printf ("Hauteur ?");
scanf ("%d", &h);
while(c < h)
{
printf("*");
c=c+1;
}
c=0;
printf("\n");
h=h-2;
while(cpt < h)
{
printf("*");
while(cpt2 < h)
{
printf(" ");
cpt2=cpt2+1;
}
printf("*\n");
cpt=cpt+1;
cpt2=0;
}
h=h+2;
while(c < h)
{
printf("*");
c=c+1;
}
printf("\n");
}
int triangle()
{
int h,cpt,c,i;
cpt=0;
printf ("Hauteur ?");
scanf("%d", &h);
while(cpt < h)
{
while(c <= i)
{
printf("*");
c=c+1;
}
i=i+1;
printf("\n");
cpt=cpt+1;
c=0;
}
}
int main(int argc, char const *argv[])
{
choice=menu(choice);
if(choice == 1)
{
choice=triangle();
}
if(choice == 2)
{
choice=carree();
}
if(choice == 3)
{
return EXIT_SUCCESS;
}
printf("%d", choice);
return EXIT_SUCCESS;
}

View File

@@ -0,0 +1,57 @@
#include<stdio.h>
#include<stdlib.h>
#include<time.h>
#define MIN -50
#define MAX 50
int affiche(int tab[])
{
int cpt=0;
int cpt2 = 0;
int cpt3 = 0;
int tab2[10];
printf("+-----+-----+-----+-----+-----+-----+-----+-----+-----+----+\n");
printf("|");
cpt3=9;
while(cpt3>=0)
{
printf("%3d | ", tab2[cpt3]);
cpt3--;
}
printf("\n+-----+-----+-----+-----+-----+-----+-----+-----+-----+----+\n");
printf("|");
cpt3=0;
return tab2[10];
}
int aleatoire(int taille){
int tab[10];
int cpt = 0;
int cpt2 = 0;
int cpt3 = 0;
srand(time(NULL));
while(cpt<10)
{
tab[cpt]=rand()%(MAX+(-MIN))+MIN;
cpt++;
}
return taille;
}
int inverse() {
int tab2[10];
int cpt2=0;
while(cpt2<=9)
{
printf("%3d | ", tab2[cpt2]);
cpt2++;
}
printf("\n+-----+-----+-----+-----+-----+-----+-----+-----+-----+----+\n");
}
int main(int argc, char* argv[])
{
int tab[10];
aleatoire(10);
affiche(tab);
inverse();
return EXIT_SUCCESS;
}

View File

@@ -0,0 +1,14 @@
#include <stdlib.h>
#include <stdio.h>
double 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;
}