« Mathc initiation/Fichiers h : x 15 » : différence entre les versions
Contenu supprimé Contenu ajouté
mAucun résumé des modifications |
Modification mineure |
||
Ligne 61 : | Ligne 61 : | ||
return((rand() % maxI) + 1); |
return((rand() % maxI) + 1); |
||
} |
} |
||
/* ------------------------------------ */ |
|||
int rndp3_I( |
|||
int maxI) |
|||
{ |
|||
int n = 0; |
|||
n = rndp_I(maxI) * 1; |
|||
n += rndp_I(maxI) * 10; |
|||
n += rndp_I(maxI) * 100; |
|||
return(n); |
|||
} |
|||
/* ------------------------------------ */ |
|||
int rndp4_I( |
|||
int maxI) |
|||
{ |
|||
int n = 0; |
|||
n = rndp_I(maxI) * 1; |
|||
n += rndp_I(maxI) * 10; |
|||
n += rndp_I(maxI) * 100; |
|||
n += rndp_I(maxI) * 1000; |
|||
return(n); |
|||
} |
|||
/* ------------------------------------ */ |
|||
int rndp5_I( |
|||
int maxI) |
|||
{ |
|||
int n = 0; |
|||
n = rndp_I(maxI) * 1; |
|||
n += rndp_I(maxI) * 10; |
|||
n += rndp_I(maxI) * 100; |
|||
n += rndp_I(maxI) * 1000; |
|||
n += rndp_I(maxI) * 10000; |
|||
return(n); |
|||
} |
|||
/* ------------------------------------ */ |
|||
/* ------------------------------------ */ |
|||
int rndp5bis_I( |
|||
void) |
|||
{ |
|||
int n = 0; |
|||
n = rndp_I(1) * 1; |
|||
n += rndp_I(2) * 10; |
|||
n += rndp_I(3) * 100; |
|||
n += rndp_I(4) * 1000; |
|||
n += rndp_I(5) * 10000; |
|||
return(n); |
|||
} |
|||
/* ------------------------------------ */ |
|||
/* ------------------------------------ */ |
|||
</syntaxhighlight> |
</syntaxhighlight> |
||
Ligne 67 : | Ligne 123 : | ||
Il y a une nouvelle fonction "void nlign(int n);", cette fonction permet d'ajouter des lignes vides dans l'écran à la place de la commande "\n". |
Il y a une nouvelle fonction "void nlign(int n);", cette fonction permet d'ajouter des lignes vides dans l'écran à la place de la commande "\n". |
||
Les fonctions int rndp*_I(int maxI); permettent de contrôler la valeur maximale de chaque chiffre d'un nombre de * chiffres. |
Version du 22 février 2022 à 15:29
Installer ce fichier dans votre répertoire de travail.
x_hfile.h utilitaire |
---|
/* ------------------------------------ */
/* Save as : x_hfile.h */
/* ------------------------------------ */
#include <stdio.h>
#include <stdlib.h>
#include <stddef.h>
#include <ctype.h>
#include <time.h>
#include <math.h>
/* ------------------------------------ */
/* ------------------------------------ */
void clrscrn(void)
{
printf("\n\n\n\n\n\n\n\n\n\n"
"\n\n\n\n\n\n\n\n\n\n"
"\n\n\n\n\n\n\n\n\n\n");
}
/* ------------------------------------ */
void nlign(int n)
{
int i;
for(i=0;i<n;i++)
printf("\n");
}
/* ------------------------------------ */
void stop(void)
{
printf(" Press return to continue. ");
getchar();
}
/* -------------- Into a while() loop - */
int stop_w(void)
{
printf("\n Press return to continue");
printf("\n Press X to stop ");
return(toupper(getchar())!='X');
}
/* ---------------------------------- */
/* ----------------------------------
Call : time_t t;
int i;
srand(time(&t));
i = rnd_I(9);
---------------------------------- */
int rndp_I(
int maxI)
{
return((rand() % maxI) + 1);
}
/* ------------------------------------ */
int rndp3_I(
int maxI)
{
int n = 0;
n = rndp_I(maxI) * 1;
n += rndp_I(maxI) * 10;
n += rndp_I(maxI) * 100;
return(n);
}
/* ------------------------------------ */
int rndp4_I(
int maxI)
{
int n = 0;
n = rndp_I(maxI) * 1;
n += rndp_I(maxI) * 10;
n += rndp_I(maxI) * 100;
n += rndp_I(maxI) * 1000;
return(n);
}
/* ------------------------------------ */
int rndp5_I(
int maxI)
{
int n = 0;
n = rndp_I(maxI) * 1;
n += rndp_I(maxI) * 10;
n += rndp_I(maxI) * 100;
n += rndp_I(maxI) * 1000;
n += rndp_I(maxI) * 10000;
return(n);
}
/* ------------------------------------ */
/* ------------------------------------ */
int rndp5bis_I(
void)
{
int n = 0;
n = rndp_I(1) * 1;
n += rndp_I(2) * 10;
n += rndp_I(3) * 100;
n += rndp_I(4) * 1000;
n += rndp_I(5) * 10000;
return(n);
}
/* ------------------------------------ */
/* ------------------------------------ */
Ce fichier contient la bibliothèque des utilitaires.
Il y a une nouvelle fonction "void nlign(int n);", cette fonction permet d'ajouter des lignes vides dans l'écran à la place de la commande "\n".
Les fonctions int rndp*_I(int maxI); permettent de contrôler la valeur maximale de chaque chiffre d'un nombre de * chiffres.