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

来源:互联网 发布:疯狂java讲义第5版mobi 编辑:程序博客网 时间:2024/04/27 23:30
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()   (双精度值 )*/

原创粉丝点击