Révision 293
Ajouté par Massamba FALL il y a presque 3 ans
branch/fall_massamba/sp4a12/main.c | ||
---|---|---|
return res;
|
||
}
|
||
|
||
double decode_longitude(char *ch)
|
||
{
|
||
// Par exemple ch = "4848.2456"
|
||
double res;
|
||
|
||
char c1[5];
|
||
char c2[5];
|
||
|
||
for (int i = 0; i < 4; i++)
|
||
{
|
||
c1[i] = ch[i];
|
||
}
|
||
|
||
for (int i = 0; i < 4; i++)
|
||
{
|
||
c2[i] = ch[i+5];
|
||
}
|
||
|
||
float partie_1 = (float) decode_nombre(c1, 4); // = 4848
|
||
float partie_2 = (float) decode_nombre(c2, 4); // = 2456=> 0.2456
|
||
|
||
res = partie_1 + partie_2 * 0.0001;
|
||
|
||
return res;
|
||
}
|
||
|
||
|
||
void test_decode_latitude()
|
||
{
|
||
if (!(fabs(decode_latitude("4545.1234") - 4545.1234 ) < 1e-10))
|
||
exit(-1);
|
||
}
|
||
|
||
void test_decode_longitude()
|
||
{
|
||
if (!(fabs(decode_latitude("4848.2456") - 4848.2456 ) < 1e-10))
|
||
exit(-1);
|
||
}
|
||
|
||
int trame_cmp(char*trame,char*type)
|
||
{
|
||
int i =0, j=0, res=1;
|
||
... | ... | |
test_decode_latitude();
|
||
}
|
||
|
||
|
||
// Ne pas modifier cette fonction
|
||
int main(int argc,char ** argv)
|
||
{
|
Formats disponibles : Unified diff
question 9 ok