Projet

Général

Profil

« Précédent | Suivant » 

Révision 300

Ajouté par malameynar il y a presque 4 ans

implémentation de la fonction lat_long ainsi que de son test (fonction de la question 11)

Voir les différences:

branch/lameynardie/sp4a12/main.c
deg=decode_nombre(ch,3)*1000000;
min=(decode_nombre(ch,9)-deg)/60;
lon=deg/1000000+min/10000;
if((ch[9]=='S')){
if((ch[9]=='O')){
lon=-lon;
}
return (lon);
}
}
float lat_float(char * ch){
float deg;
float min;
......
deg=decode_nombre(ch,2)*1000000;
min=(decode_nombre(ch,8)-deg)/60;
lat=deg/1000000+min/10000;
if((ch[8]=='O')){
if((ch[8]=='S')){
lat=-lat;
}
return (lat);
}
float lat_long(char* ch){
if (decode_int(ch[8])==-1){
return(lat_float(ch));
}
else{
return(lon_float(ch));
}
}
test_decode_nombre(void){
int i;
char chaine [50]="987654321";
char chaine []="987654321";
for(i=1;i<10;i++){
printf("%d\n",decode_nombre(chaine,i));
}
}
test_lon_float(void){
char longi[9]="003066036E";
char longi[]="003066036E";
printf("longitude\n%f\n",lon_float(&longi));
}
test_lat_float(void){
char lati[8]="37232475N";
char lati[]="37232475S";
printf("latitude\n%f\n",lat_float(&lati));
}
}
test_lat_long(void){
char lati1[]="37232475N";
char longi1[]="003066036E";
char lati2[]="37232475S";
char longi2[]="003066036O";
printf("latitude:%f\n",lat_long(&lati1));
printf("latitude:%f\n",lat_long(&longi1));
printf("latitude:%f\n",lat_long(&lati2));
printf("latitude:%f\n",lat_long(&longi2));
}
/*
float lon_float(char * trame)
int i=17;
......
// test_decode_int();
// test_decode_nombre();
test_lon_float();
test_lat_float();
test_lat_float();
test_lat_long();
}
void test_decode_int(void){

Formats disponibles : Unified diff