Mathc initiation/Fichiers c : c15h

Un livre de Wikilivres.
Aller à la navigation Aller à la recherche


Sommaire


Installer et compiler ces fichiers dans votre répertoire de travail.

Crystal Clear mimetype source c.png a08_fun.c
/* ---------------------------------- */
/*  Save as :   a08_fun.c             */
/* ---------------------------------- */
#include    "x_hfile.h"
/* ---------------------------------- */
/* ---------------------------------- */
int main(void)
{
time_t t;

int i=0,j=0,n=1,loop=0;

  srand(time(&t));
  
  
/* ---------------------------------- */ 
loop=5;  
do{clrscrn();
	
   printf("Addition\n\n\n\n");   
   printf(" i+j: %10d      \n\n",j+i);
   
   j  = rp_I (900)+99;
   i  = rp_I (900)+99;
   
   printf("   j: %10d         \n",j    );
   printf("  +i: %10d       (%d)",i,n++);
   
   nlign(6);   
   stop();

}while(n<=loop);

clrscrn();

   printf("Addition\n\n\n\n");   
   printf(" i+j: %10d      (%d)\n\n",j+i,--n);

nlign(9);   
stop();


/* ---------------------------------- */
loop=5;
i=0,j=0,n=1;

do{clrscrn();
	
   printf("Soustraction\n\n\n\n");   
   printf(" j-i: %10d      \n\n",j-i);
   
   j  = rp_I (900)+99;
   i  = rp_I ( 90)+9;
   
   printf("   j: %10d         \n",j    );
   printf("  -i: %10d       (%d)",i,n++);
   
   nlign(6);   
   stop();

}while(n<=loop);

clrscrn();

   printf("Soustraction\n\n\n\n");   
   printf(" j-i: %10d      (%d)\n\n",j-i,--n);

nlign(9);   
stop();


/* ---------------------------------- */
loop=6;
n=1,i=0;

do{clrscrn();
   
   printf("division\n\n\n\n");
   printf("  %d \n\n",i);
   
   i = rp_I (90)+9;
   j = rp_I (9);
   
   if(n<loop) printf("  %d / %d  (%d) ",i*j,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");             
   printf(" r = %d          (%d) \n\n",(i%j),(n-1));  
   
   i  =   rp_I (90)+9;
   j  =   rp_I ( 7)+2;  
    
   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  = -(rp_I (90)+9);
   j  =   rp_I ( 7)+2 ;
   
   if(n<loop) printf(" r = %d  %% %d    (%d) ",i,j,n++);
   else       n++;

   nlign(6);  
   stop();

}while(n<=loop);


/* ---------------------------------- */
loop=6;
n=1,i=0;

do{clrscrn();
	
   printf("Multiplication 2\n\n\n\n");
   printf("  %d           \n\n",i*j);
   
   i = rp_I(90)+9;
   j = rp_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;

do{clrscrn();
	
   printf("Carre 2\n\n");
   printf("  %d           \n\n",i*j);
   
   i = j =  rp_I(90)+9;
   
   if(n<loop) printf("  %d * %d  (%d)",i,j,n++);
   else       n++;
   
   nlign(6);   
   stop();

}while(n<=loop);


/* ---------------------------------- */
loop=3;
i=0,n=1;

do{clrscrn();
	
   printf("Multiplication 3\n\n\n");
   printf("  %d           \n\n",i*j);
   
   i = rp3_I(5);
   j = rp3_I(5);
   
   if(n<loop) printf("     %4d\n    *%4d  (%d)",i,j,n++);
   else       n++;
   
   nlign(6);  
   stop();

}while(n<=loop);


/* ---------------------------------- */
loop=3;
i=0,n=1;

do{clrscrn();
	
   printf("Carre 3\n\n");
   printf("  %d           \n\n",i*j);
   
   i = j = rp3_I(5);
 
   if(n<loop) printf("     %4d\n    *%4d  (%d)",i,j,n++);
   else       n++;
   
   nlign(6);  
   stop();

}while(n<=loop);


/* ---------------------------------- */
loop=2;
i=0,n=1;

do{clrscrn();
	
   printf("Multiplication 4 \n\n");
   printf("  %d             \n\n",i*j   );
   
   i = rp4_I(5);
   j = rp4_I(5);
   
   if(n<loop) printf("     %4d\n    *%4d  (%d)",i,j,n++);
   else       n++;
   
   nlign(6);  
   stop();

}while(n<=loop);


/* ---------------------------------- */
loop=2;
i=0,n=1;

do{clrscrn();
	
   printf("Carre 4 \n\n");
   printf("  %d    \n\n",i*j);
   
   i =j = rp4_I(5);
 
   if(n<loop) printf("     %4d\n    *%4d  (%d)",i,j,n++);
   else       n++;
   
   nlign(6);  
   stop();

}while(n<=loop);


 return 0;
}
/* ---------------------------------- */
/* ---------------------------------- */


C'est un petit utilitaire pour s'entraîner aux calculs (30 minutes).