Mathc complexes/Fichiers c : swap c
Apparence
Installer et compiler ce fichier dans votre répertoire de travail.
swapc.c |
---|
/* ------------------------------------ */
/* Save as : swapc.c */
/* ------------------------------------ */
#include "w_a.h"
/* ------------------------------------ */
int take_c(int c)
{
int r = c;
if(r!=C1) r= (c-C1)*C2+C1;
return(r);
}
/* ------------------------------------ */
int main(void)
{
double a[R3*(C3*C2)] ={ 1,1, 2,2, 3,3,
1,1, 2,2, 3,3,
1,1, 2,2, 3,3};
double **A = ca_A_mZ(a,i_mZ(R3,C3));
int c1 = take_c(C1);
int c2 = take_c(C3);
clrscrn();
printf(" A :");
p_mZ(A, S5,P0, S4,P0, C6);
printf(" swapC_mZ(A,C%d,C%d)\n\n",c1,((c2-C1)/C2)+C1);
printf(" A :");
p_mZ(swapC_mZ(A,c1,c2), S5,P0, S4,P0, C6);
f_mZ(A);
stop();
return 0;
}
/* ------------------------------------ */
/* ------------------------------------ */
La fonction swapC_mZ(); échange deux colonnes.
Exemple de sortie écran :
A :
+1 +1i +2 +2i +3 +3i
+1 +1i +2 +2i +3 +3i
+1 +1i +2 +2i +3 +3i
swapC_mZ(A,C1,C3)
A :
+3 +3i +2 +2i +1 +1i
+3 +3i +2 +2i +1 +1i
+3 +3i +2 +2i +1 +1i
Press return to continue.