Révision 266
Ajouté par malameynar il y a presque 4 ans
main.c | ||
---|---|---|
int x=0;
|
||
for(i=0;i<n;i++){
|
||
|
||
x=x+decode_int(ch[i])*pow(10,n-1-i);
|
||
x=x*10+decode_int(ch[i]);
|
||
}
|
||
return(x);
|
||
}
|
||
|
||
float lon_float(char * ch){
|
||
int deg;
|
||
int min;
|
||
float deg;
|
||
float min;
|
||
float lon=0;
|
||
deg=decode_nombre(ch,2);
|
||
min=decode_nombre(ch,8)-deg*1000000;
|
||
lon=deg+min/60;
|
||
if ((ch[8]!=78) && (ch[8]!=83)){
|
||
return(200);
|
||
deg=decode_nombre(ch,3)*1000000;
|
||
min=(decode_nombre(ch,9)-deg)/60;
|
||
lon=deg/1000000+min/10000;
|
||
if((ch[9]=='S')){
|
||
lon=-lon;
|
||
}
|
||
else{
|
||
if(ch[8]=83){
|
||
lon=-lon;
|
||
}
|
||
return (lon);
|
||
|
||
}
|
||
float lat_float(char * ch){
|
||
float deg;
|
||
float min;
|
||
float lat=0;
|
||
deg=decode_nombre(ch,2)*1000000;
|
||
min=(decode_nombre(ch,8)-deg)/60;
|
||
lat=deg/1000000+min/10000;
|
||
if((ch[8]=='O')){
|
||
lat=-lat;
|
||
}
|
||
return (lon);
|
||
return (lat);
|
||
}
|
||
test_decode_nombre(void){
|
||
int i;
|
||
char chaine [50]="987654321";
|
||
for(i=1;i<10;i++){
|
||
printf("%d\n",decode_nombre(chaine,i));
|
||
}
|
||
}
|
||
test_lon_float(void){
|
||
char longi[9]="003066036E";
|
||
printf("longitude\n%f\n",lon_float(&longi));
|
||
}
|
||
test_lat_float(void){
|
||
char lati[8]="37232475N";
|
||
printf("latitude\n%f\n",lat_float(&lati));
|
||
}
|
||
/*
|
||
float lon_float(char * trame)
|
||
int i=17;
|
||
... | ... | |
}
|
||
// test_decode_int();
|
||
// test_decode_nombre();
|
||
test_lon_float();
|
||
test_lon_float();
|
||
test_lat_float();
|
||
}
|
||
|
||
test_decode_int(void){
|
||
void test_decode_int(void){
|
||
|
||
int i;
|
||
|
||
|
||
for(i=0;i<128;i++){
|
||
printf("%c",i);
|
||
if(i>47 && i<58){
|
||
... | ... | |
}
|
||
}
|
||
}
|
||
test_decode_nombre(void){
|
||
int i;
|
||
char chaine [50]="987654321";
|
||
for(i=1;i<10;i++){
|
||
printf("%d\n",decode_nombre(chaine,i));
|
||
}
|
||
}
|
||
test_lon_float(void){
|
||
printf("%d",);
|
||
printf("nique sa race %f",lon_float("00636036N"));
|
||
}
|
||
|
||
|
||
// Ne pas modifier cette fonction
|
||
int main(int argc,char ** argv)
|
Formats disponibles : Unified diff
implantation des fonction des question 9 et 10 lon_float et lat_float