Révision 274
Ajouté par yoguer il y a environ 4 ans
main.c | ||
---|---|---|
{
|
||
a=-1; //renvoie -1 si autres caract?res que 0 ? 9
|
||
}
|
||
|
||
switch(c)
|
||
{
|
||
case 'N':
|
||
a=1;
|
||
break;
|
||
case 'S':
|
||
a=2;
|
||
break;
|
||
case 'E':
|
||
a=3;
|
||
break;
|
||
case 'O':
|
||
a=4;
|
||
break;
|
||
}
|
||
return a;
|
||
}
|
||
|
||
|
||
int decode_nombre(char *ch,int n)
|
||
{
|
||
int tab[n],i,retour=0;
|
||
int tab[n],i,retour=0,memoire=0;
|
||
|
||
for(i=0;i<n;i++)
|
||
{
|
||
... | ... | |
if(tab[i]!= -1)
|
||
{
|
||
retour=(retour*10)+tab[i];
|
||
//printf("%d\n",);
|
||
memoire++;
|
||
}
|
||
}
|
||
printf("%d\n",retour);
|
||
|
||
if((ch[memoire+2]=='S')||(ch[memoire+2]=='W'))
|
||
{
|
||
retour=retour*(-1);
|
||
}
|
||
|
||
return retour;
|
||
}
|
||
|
||
|
||
float conversion_sexa(char *latitude)
|
||
{
|
||
int tram=decode_nombre(latitude,15);
|
||
float reste,resultat;
|
||
int tram=decode_nombre(latitude,12);
|
||
printf("%d\n",tram);
|
||
|
||
int degres=tram/10000000;
|
||
printf("%d\n",degres);;
|
||
int degres=(tram/1000000);
|
||
reste=(tram-(degres*1000000));
|
||
reste=(reste/10000);
|
||
resultat=(degres+(reste/60));
|
||
|
||
return resultat;
|
||
}
|
||
|
||
|
||
... | ... | |
|
||
test_decode_int(); //test la fonction decode_int
|
||
test_decode_nombre(); //test la fonction decode_nombre
|
||
test_conversion_latitude(); //test la fonction conversion_char_latitude
|
||
test_conversion_latitude_longitude(); //test la fonction conversion_char_latitude
|
||
}
|
||
|
||
|
||
... | ... | |
}
|
||
|
||
|
||
void test_conversion_latitude(void)
|
||
void test_conversion_latitude_longitude(void)
|
||
{
|
||
char *trame_latitude;
|
||
trame_latitude="136306.6036,E";
|
||
trame_latitude="3723.2475,S";
|
||
float retour;
|
||
|
||
conversion_sexa(trame_latitude);
|
||
//printf("%f",retour);
|
||
retour=conversion_sexa(trame_latitude);
|
||
printf("retour=%f\n",retour);
|
||
}
|
||
|
||
|
Formats disponibles : Unified diff
Modif programme