赤纬转换为度 (字符切割和字符类型转换 string→double)

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/m0_37848360/article/details/77097255
double dectod(string a) //赤纬转化为度
{
string a=" 32d30  -29d55";
string b=a.substr(0.1);
if(b=="-")
{
string c=a.substr(1,2);
double c1=atof(c.c_str());
string d=a.substr(5,2);
double d1=atof(d.c_str());
double d2=(double)d1/60;
return -(c1+d2);
}
else
{
string e=a.substr(0,2);
double e1=atof(e.c_str());
string f=a.substr(3,2);
double f1=atof(f.c_str());
double f2=(double)f1/60;
return e1+f2;
}

}

/*string→int  atoi()

string→long int  atol()

string→doble  atof()   (双精度值 )*/

猜你喜欢

转载自blog.csdn.net/m0_37848360/article/details/77097255