« Mathc initiation/Fichiers c : c15h » : différence entre les versions

Contenu supprimé Contenu ajouté
m typo
Modification mineure
Ligne 13 :
#include "x_ahfile.h"
/* ---------------------------------- */
#define LOOP 5
/* ---------------------------------- */
int main(void)
Ligne 19 ⟶ 18 :
time_t t;
 
int i=0,j=0,n=1,loop=LOOP+10;
 
srand(time(&t));
loop=10;
do{clrscrn();
Ligne 29 :
printf(" i+j: %10d \n\n",j+i);
j = rndp_I (900090000)+9999999;
i = rndp_I (900090000)+9999999;
printf(" j: %10d \n",j );
printf(" +i: %10d (%d)",i,n++);nlign(6);
nlign(6);
stop();
 
}while(stop_w()n<=loop);
 
clrscrn();
Ligne 43 ⟶ 46 :
 
nlign(9);
getcharstop();
 
 
loop=10;
stop();
i=0,j=0,n=1;
 
Ligne 54 ⟶ 57 :
printf(" j-i: %10d \n\n",j-i);
j = rndp_I (900090000)+9999999;
i = rndp_I ( 9009000)+99999;
printf(" j: %10d \n",j );
printf(" -i: %10d (%d)",i,n++);nlign(6);
nlign(6);
stop();
 
}while(stop_w()n<=loop);
 
clrscrn();
Ligne 68 ⟶ 74 :
 
nlign(9);
getcharstop();
 
 
loop=6;
stop();
n=1,i=0;
 
Ligne 92 ⟶ 98 :
 
 
loop=6;
n=1,i=0;
 
do{clrscrn();
printf("Carre 2\n\n");
printf(" %d \n\n",i*j);
i = j = rndp_I(90)+9;
if(n<loop) printf(" %d * %d (%d)",i,j,n++);
else n++;
nlign(6);
stop();
 
}while(n<=loop);
 
 
loop=6;
n=1,i=0;
 
Ligne 111 ⟶ 137 :
 
 
loop=2;
 
i=0,n=1;
 
Ligne 119 ⟶ 145 :
printf(" %d \n\n",i*j);
i = rndp_Irndp3_I(4905)+9+100;
j = rndp_Irndp3_I(4905)+9+100;
if(n<loop) printf(" %4d\n *%4d (%d)",i,j,n++);
Ligne 132 ⟶ 158 :
 
 
loop=2;
i=1,j=1,n=1;
i=0,n=1;
 
do{clrscrn();
printf("r = a %% b Carre 3\n\n");
printf(" r = %d (%d) \n\n",(i%*j),(n-1));
i = j = rndp_I rndp3_I(905)+9;
j = rndp_I ( 7)+2;
if(n<loop) printf(" %4d\n *%4d (%d)",i,j,n++);
if(n<loop) printf(" r = %d %% %d (%d) ",i,j,n++);
else n++;
 
nlign(6);
stop();
Ligne 152 ⟶ 178 :
 
 
loop=2;
i=1,j=1,n=1;
i=0,n=1;
 
do{clrscrn();
printf("r = (-)a %% b Multiplication 4 \n\n");
printf(" %d \n\n",i*j );
if((i%j)) printf(" r = %d (%d) \n\n",(i%j)+j,(n-1));
else printf(" r = %d (%d) \n\n", 0, (n-1));
i = -(rndp_I (90)+9);
j = rndp_I ( 7)+2 ;
i = rndp4_I(5);
if(n<loop) printf(" r = %d %% %d (%d) ",i,j,n++);
j = rndp4_I(5);
if(n<loop) printf(" %4d\n *%4d (%d)",i,j,n++);
else n++;
 
nlign(6);
stop();
Ligne 174 ⟶ 199 :
 
 
loop=2;
n=1,i=0;
i=0,n=1;
 
do{clrscrn();
printf("Carre 24 \n\n");
printf(" %d \n\n",i*j);
i = j = rndp_Irndp4_I(905)+9;
if(n<loop) printf(" %d4d\n * *%d4d (%d)",i,j,n++);
else n++;
nlign(6);
stop();
 
Ligne 193 ⟶ 219 :
 
 
loop=2;
i=0,n=1;
 
do{clrscrn();
printf("CarreMultiplication 5 3\n\n");
printf(" %d \n\n",i*j );
i = rndp5_I(5);
j = rndp5_I(5);
i = j = rndp_I(490)+9+100;
if(n<loop) printf(" %4d\n *%4d (%d)",i,j,n++);
else n++;
Ligne 212 ⟶ 240 :
 
 
loop=LOOP-4+12;
i=0,n=1;
 
do{clrscrn();
printf("MultiplicationCarre 45 \n\n");
printf(" %d \n\n",i*j );
i = rndp_I(4900)+9+1000;
j = rndp_I(4900)+9+1000;
i =j =rndp5_I(5);
if(n<loop) printf(" %4d\n *%4d (%d)",i,j,n++);
else n++;
Ligne 233 ⟶ 260 :
 
 
loop=LOOP+16;
i=01,j=1,n=1;
 
do{clrscrn();
printf("Carrer = a %% b 4 \n\n");
printf(" r = %d (%d) \n\n",(i*%j),(n-1));
i =j = rndp_I (490090)+9+1000;
j = rndp_I ( 7)+2;
if(n<loop) printf(" %4d\n *%4d (%d)",i,j,n++);
if(n<loop) printf(" r = %d %% %d (%d) ",i,j,n++);
else n++;
 
nlign(6);
stop();
 
}while(n<=loop);
 
 
loop=6;
i=1,j=1,n=1;
 
do{clrscrn();
printf("r = (-)a %% b \n\n");
if((i%j)) printf(" r = %d (%d) \n\n",(i%j)+j,(n-1));
else printf(" r = %d (%d) \n\n", 0, (n-1));
i = -(rndp_I (90)+9);
j = rndp_I ( 7)+2 ;
if(n<loop) printf(" r = %d %% %d (%d) ",i,j,n++);
else n++;
 
nlign(6);
stop();
Ligne 254 ⟶ 304 :
return 0;
}
/* ---------------------------------- */
/* ---------------------------------- */
 
</syntaxhighlight>
 
 
C'est un petit utilitaire pour s'entraîner aux calculs (30 minutes).
 
De petites corrections ont été effectuées par rapport aux exemples précédents.
 
Pour passer d'une opération à la suivante vous devez appuyer sur la touche "return", sauf pour sortir des boucles de l'addition et de la soustraction, ou dans ce cas vous appuyez sur deux touches "x" et "return". Pour conserver le bon fonctionnement du programme il faut neutraliser l'une des deux touches. C'est ce que font les "getchar()" dans ce listing. '''Ce type de bug apparaîtra régulièrement dans nos travaux'''.