Aller au contenu

Mathc matrices/Fichiers c : p03a

Un livre de Wikilivres.


Étude du code


Installer et compiler ce fichier dans votre répertoire de travail.

p03a.c
/* ------------------------------------ */
/*  Save as :   c00.c                   */
/* ------------------------------------ */
#include "v_a.h"
/* ------------------------------------ */
/* ------------------------------------ */
double **Xpall_mR(
double **A,  // R3xC8
int er,
int dr,
int n_cMAX   // C9
)
{
int r;
int c;

int c_LAST;
int c_FIRST;

int THE_LAST_c_TO_WRITE = C0;

      //        C0        <    C9
while(THE_LAST_c_TO_WRITE < A[C_SIZE][C0])
     {
		 
	               c_FIRST = THE_LAST_c_TO_WRITE; //C0	 
	 
      THE_LAST_c_TO_WRITE += n_cMAX;  //C0+C9=C9
                            
            //       C9      <     C9               
      if(THE_LAST_c_TO_WRITE < A[C_SIZE][C0])       
                              c_LAST  = THE_LAST_c_TO_WRITE; 
      else                             //    C9
                              c_LAST  = A[C_SIZE][C0];  //C9
              
      //       R0<R4
 	  for(r=R0; r<A[R_SIZE][C0]; r++)
         {
          //             C0<C9
 	      for (c=c_FIRST; c<c_LAST; c++)
 	                                     //     Rr Rc
               if(!c)                                   // If we are in C0 then print ___1, ___2, ...
                   printf("%-+*.*f ",er+C3,P0,A[r][c]);
               else if(!r)                              // If we are in R0 then print 1, 2, ...
                   printf("%+*.*f " ,er,   P0,A[r][c]);
               else                                     // Else then print x.xx, x.xx, ...
                   printf("%+*.*f ", er,   dr,A[r][c]);
               
               
          if(!r)
                  printf("\n\n");
          else   
                  printf("\n");      
          }
          
      printf("\n");
     }
     
return(A);
}
/* ------------------------------------ */
/* ------------------------------------ */
int main(void)
{
  double **A = i_mR(R3,C8);
  
  
/* ------------------------------------ */  
  clrscrn();  
  r_mR(A,99.); 
  printf("  x = +22    .   333  \n"
         " Sn =  S3 + P1 + P3 = S%d\n\n", S3+P1+P3);
  Xpall_mR(A,    S3 + P1 + P3,
                           P3,C3);   
  stop();
/* ------------------------------------ */  
/* ------------------------------------ */   
  clrscrn();  
  r_mR(A,9999.); 
  printf("  x = +4444    .   333  \n"
         " Sn =    S5 + P1 + P3 = S%d\n\n", S5+P1+P3);
  Xpall_mR(A,      S5 + P1 + P3,
                             P3,C3);   
  stop();  
/* ------------------------------------ */  
/* ------------------------------------ */    
  clrscrn();  
  r_mR(A,9999.); 
  printf("  x = +4444    .    0  \n"
         " Sn =    S5 + P0 + P0 = S%d\n\n", S5+P0+P0);
  Xpall_mR(A,      S5 + P0 + P0,
                             P0,C3);   
  stop();   
/* ------------------------------------ */  
/* ------------------------------------ */    
  clrscrn();  
  rE_mR(A,9999.,1E-4); 
  printf("  x =    +0    . 4444 \n"
         " Sn =    S2 + P1 + P4 = S%d\n\n", S2+P1+P4);
  Xpall_mR(A,      S2 + P1 + P4,
                             P4,C3);   
  stop();  
/* ------------------------------------ */ 
/* ------------------------------------ */    
  clrscrn();  
  rE_mR(A,999999.,1E-4); 
  printf("  x =   +22    . 4444 \n"
         " Sn =    S3 + P1 + P4 = S%d\n\n", S3+P1+P4);
  Xpall_mR(A,      S3 + P1 + P4,
                             P4,C3);   
  stop();  
/* ------------------------------------ */ 
/* ------------------------------------ */      
  
  f_mR(A);
  
  return 0;
}
/* ------------------------------------ */
/* ------------------------------------ */
 x = +22.123
     +22    .   123
Sn =  S3 + P1 +  P3 = S7


Sn : Présente la méthode que j'ai utilisé pour calculer l'espace que j'ai laissé entre les nombres.

Exemple de sortie écran :

  x = +22    .   333  
 Sn =  S3 + P1 + P3 = S7

+4              +1      +2 

+9         +29.000 -73.000 
+0         +43.000 +80.000 
+0         +55.000 -96.000 

     +3      +4      +5 

-24.000 +56.000 -70.000 
+99.000 -61.000 +27.000 
+74.000 +14.000 -52.000 

     +6      +7      +8 

-42.000  -6.000 +96.000 
-45.000 -92.000 +33.000 
-82.000 -78.000 +60.000 

 Press return to continue. 
/* ------------------------------------ */
/* ------------------------------------ */
  x = +4444    .   333  
 Sn =    S5 + P1 + P3 = S9

+4                  +1        +2 

+9           +3297.000 +9381.000 
+0           -7608.000 -1430.000 
+0           +8819.000 +1798.000 

       +3        +4        +5 

+7373.000 -1152.000  +645.000 
-1391.000  -298.000 -3574.000 
+3876.000 -4579.000 -8001.000 

       +6        +7        +8 

-5297.000 -3481.000  -852.000 
-8724.000 +6492.000 +1492.000 
+5353.000  +846.000 +2144.000 

 Press return to continue. 
/* ------------------------------------ */
/* ------------------------------------ */
  x = +4444    .    0  
 Sn =    S5 + P0 + P0 = S5

+4          +1    +2 

+9       +1799 -5044 
+0       +3311 -4563 
+0       -1738 +7744 

   +3    +4    +5 

+4420 +5520 -9180 
-3373 -4871  -599 
-5028 -7315 -2255 

   +6    +7    +8 

+7782 +6388 +5462 
-4438 -9592 -1480 
+1464 -7535 -7014 

 Press return to continue. 
/* ------------------------------------ */
/* ------------------------------------ */
  x =    +0    . 4444 
 Sn =    S2 + P1 + P4 = S7

+4              +1      +2 

+9         -0.7348 +0.9613 
+0         +0.5511 +0.8919 
+0         -0.7263 +0.5950 

     +3      +4      +5 

-0.0719 -0.3677 -0.7873 
+0.4610 +0.6329 +0.1332 
-0.8555 +0.0882 -0.0906 

     +6      +7      +8 

-0.4344 -0.7860 -0.2021 
+0.7090 +0.7881 -0.1294 
-0.5476 -0.4212 -0.9945 

 Press return to continue. 
/* ------------------------------------ */
/* ------------------------------------ */
  x =   +22    . 4444 
 Sn =    S3 + P1 + P4 = S8

+4                +1       +2 

+9          -90.9841  +6.5895 
+0           +0.4814 +23.6524 
+0          +38.6246 -61.9050 

      +3       +4       +5 

-36.7933 -33.7804 +32.0880 
-79.8721 +57.1422  -4.4031 
+50.3967 +90.9697 +30.9265 

      +6       +7       +8 

-96.6383 +11.6046 +11.8959 
-25.9630 -29.8971 -69.0869 
-11.1131 +76.0096 -37.8138 

 Press return to continue.