Pb avec les format dans printf
Résolu
tazgaga
Messages postés
9
Statut
Membre
-
tazgaga Messages postés 9 Statut Membre -
tazgaga Messages postés 9 Statut Membre -
Bonjour,
Voila je dois concocter un petit programme sur les polynômes j'en suis à l'affichage du polynome que je souhaite par exemple 6x^4 - 2x^3 + x - 34 voilà donc pour cela j'ai écrit ce code :
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#define DMAX 50 /*degré maximal du polynôme*/
typedef float T_Vect [DMAX+1];
typedef struct {int D; T_Vect T;} T_Poly;
void Affiche_Poly (T_Poly P)
{
int I;
char signe;
printf("(");
if (abs(P.T[P.D]==1))
printf("x^%d",P.D);
else(P.T[P.D]!=0.);
{
if (P.T[P.D]<0.)
{
signe='-';
printf("%c %2lfx^%d",signe,abs(P.T[P.D]),P.D); /*A ce niveau*/
}
else printf("%2lfx^%d",abs(P.T[P.D]),P.D); /*A ce niveau */
}
for (I=P.D-1;I>=0;I--)
{
if (abs(P.T[I])==1)
printf("x^%d",I);
if (P.T[I] < 0.)
{
signe='-';
printf("%c%2lfx^%d",signe,abs(P.T[I]),I); /*a ce niveau */
}
else
printf("%2lfx^%d",abs(P.T[I]),I); /*a ce niveau*/
}
printf(")\n");
}
int main (void)
{
T_Poly P;
P=Lire_Poly();
printf("P(x)=");
Affiche_Poly(P);
return 0;
}
Mais au niveau des lignes marquès (a ce niveau) le compilateur renvoie ce message d'errueurs
projetme.c: In function ‘Affiche_Poly’:
projetme.c:73: warning: format ‘%2lf’ expects type ‘double’, but argument 3 has type ‘int’
projetme.c:75: warning: format ‘%2lf’ expects type ‘double’, but argument 2 has type ‘int’
projetme.c:85: warning: format ‘%2lf’ expects type ‘double’, but argument 3 has type ‘int’
projetme.c:89: warning: format ‘%2lf’ expects type ‘double’, but argument 2 has type ‘int’
Voila je dois concocter un petit programme sur les polynômes j'en suis à l'affichage du polynome que je souhaite par exemple 6x^4 - 2x^3 + x - 34 voilà donc pour cela j'ai écrit ce code :
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#define DMAX 50 /*degré maximal du polynôme*/
typedef float T_Vect [DMAX+1];
typedef struct {int D; T_Vect T;} T_Poly;
void Affiche_Poly (T_Poly P)
{
int I;
char signe;
printf("(");
if (abs(P.T[P.D]==1))
printf("x^%d",P.D);
else(P.T[P.D]!=0.);
{
if (P.T[P.D]<0.)
{
signe='-';
printf("%c %2lfx^%d",signe,abs(P.T[P.D]),P.D); /*A ce niveau*/
}
else printf("%2lfx^%d",abs(P.T[P.D]),P.D); /*A ce niveau */
}
for (I=P.D-1;I>=0;I--)
{
if (abs(P.T[I])==1)
printf("x^%d",I);
if (P.T[I] < 0.)
{
signe='-';
printf("%c%2lfx^%d",signe,abs(P.T[I]),I); /*a ce niveau */
}
else
printf("%2lfx^%d",abs(P.T[I]),I); /*a ce niveau*/
}
printf(")\n");
}
int main (void)
{
T_Poly P;
P=Lire_Poly();
printf("P(x)=");
Affiche_Poly(P);
return 0;
}
Mais au niveau des lignes marquès (a ce niveau) le compilateur renvoie ce message d'errueurs
projetme.c: In function ‘Affiche_Poly’:
projetme.c:73: warning: format ‘%2lf’ expects type ‘double’, but argument 3 has type ‘int’
projetme.c:75: warning: format ‘%2lf’ expects type ‘double’, but argument 2 has type ‘int’
projetme.c:85: warning: format ‘%2lf’ expects type ‘double’, but argument 3 has type ‘int’
projetme.c:89: warning: format ‘%2lf’ expects type ‘double’, but argument 2 has type ‘int’
A voir également:
- Pb avec les format dans printf
- Format epub - Guide
- Format factory - Télécharger - Conversion & Codecs
- Hp usb disk storage format tool - Télécharger - Stockage
- Format apfs - Guide
- Format bin - Guide