![Citation](https://forum.developpez.be/images/misc/quote_icon.png)
Envoyé par
s-ehtp
j'attends vos commentaires!!
Déjà, tu peux corriger ça :
1 2 3 4 5 6 7 8 9 10 11 12
|
Project : Forums
Compiler : GNU GCC Compiler (called directly)
Directory : D:\dev\forums\
--------------------------------------------------------------------------------
Switching to target: default
Compiling: main.c
main.c:15: warning: function declaration isn't a prototype
main.c:15: warning: return type of 'main' is not `int'
Linking console executable: console.exe
Process terminated with status 0 (0 minutes, 0 seconds)
0 errors, 2 warnings |
Ensuite, ceci :
fait varier i de 0 à n, soit n+1 fois...
L'expression idiomatique est
et ce n'est certainement pas un hasard...
D'autre part, le format "%40le" est correct mais fantaisiste. Je recommande :
printf ("%8.2f", T[i][j]);
Ceci fonctionne correctement :
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43
|
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#define Nmax 100
int f (int l)
{
return l;
}
double g (int m)
{
return cos (m);
}
int main (void)
{
double T[Nmax][Nmax];
int i, j, n;
do
{
printf ("donner n:\n");
scanf ("%d", &n);
}
while (!(n <= Nmax));
for (i = 0; i < n; i++)
T[i][0] = g (i);
for (j = 1; j < n; j++)
for (i = j; i < n; i++)
T[i][j] = (T[i][j - 1] - T[i - 1][j - 1]) / (f (i) - f (i - j));
printf ("la matrice resultat est :\n");
for (i = 0; i < n; i++)
{
for (j = 0; j < n; j++)
printf ("%8.2f", T[i][j]);
printf ("\n");
}
return 0;
} |
1 2 3 4 5 6 7 8 9 10 11 12
|
donner n:
6
la matrice resultat est :
1.00 0.00 0.00 0.00 0.00 0.00
0.54 -0.46 0.00 0.00 0.00 0.00
-0.42 -0.96 -0.25 0.00 0.00 0.00
-0.99 -0.57 0.19 0.15 0.00 0.00
-0.65 0.34 0.46 0.09 -0.01 0.00
0.28 0.94 0.30 -0.05 -0.03 -0.00
Press ENTER to continue. |
Partager