当前位置:首页 » 编程语言 » c语言知道经度求带号
扩展阅读
webinf下怎么引入js 2023-08-31 21:54:13
堡垒机怎么打开web 2023-08-31 21:54:11

c语言知道经度求带号

发布时间: 2022-04-13 21:44:27

c语言的作业,求救,怎么做啊

#include<stdio.h>

int main()

{

int a[4],b[4];

int k=1,j=1,x,y,t;

scanf("%d%d",&x,&y);

while(x!=0)

{

a[k++]=x%10;//把x的各个位提取出来

x/=10;

}

while(y!=0)

{

b[j++]=y%10;//把y的各个提取出来

y/=10;

}

t=a[2];

a[2]=b[2];//十位交换

b[2]=t;

for(int i=3;i>=1;i--)

{

printf("%d",a[i]);

}

printf(" ");

for(int i=3;i>=1;i--)

{

printf("%d",b[i]);

}

return 0;

}

⑵ 怎样用c语言编写下面这个问题,困扰我好多天了:

解题思路是这样的:
1、先计算两城市的径度间隔α。 因为东经180度和西经180度重合,所以只要两城市在同一侧(如都是东经)就取差值;在不同侧 就取和,但和如超过180度,就要用360度来减,才是实际的经度差α。

2、再求出两城市(A、B)与地心连线之间的夹角β。【估计你被困在这里】
如果A、B在赤道上,那么β就是经度差α,而如果都在极点,β就等于0,在此之间呢?β等于α乘以纬度的余弦,即 β=α*cos(纬度值) 。推理过程从略,自己去想哈。

3、地球周长*β/360 就是两地的距离啦

代码你自己整吧,应该木有问题吧?

⑶ C语言实现经纬度的转换

办法很多,三维字符数组,指针字符数组都可以,分别保存字符串到数组元素,最后以%s输出即可。
我来写个最简单的

#include "stdafx.h"
#include "stdlib.h"
#include "string.h"

void explain_NS(char * str)
{
char tmp_ca[30] = "";
if(str[0] == 'N')
strcpy(tmp_ca,"北纬");
else
strcpy(tmp_ca,"南纬");
char *p = tmp_ca;
while(*p) p++;
strncpy(p, str+1, 2);
p += 2;
*p = 176;
p ++;
strncpy(p,str+3,2);
p += 2;
*p = 39;
p++;
strncpy(p, str+6,5);
p += 5;
*p = 34;
printf("%s\n",tmp_ca);
}
void explain_EW(char * str)
{
char tmp_ca[30] = "";
if(str[0] == 'E')
strcpy(tmp_ca,"东经");
else
strcpy(tmp_ca,"西经");
char *p = tmp_ca;
while(*p) p++;
strncpy(p, str+1, 3);
p += 3;
*p = 176;
p ++;
strncpy(p,str+4,2);
p += 2;
*p = 39;
p++;
strncpy(p, str+7,5);
p += 5;
*p = 34;
printf("%s\n",tmp_ca);
}
int _tmain(int argc, _TCHAR* argv[])
{
char ca[30] = "N3018.93661";
char cb[30] = "E12022.88281";
explain_NS(ca);
explain_EW(cb);
system("pause");
return 0;
}

⑷ 如何根据给定经纬度进行分区 c语言实现

代码如下,VS2012亲测,可以运行,给你注释的很清楚了,不懂的地方可以问我。
#include <windows.h>
#include <stdio.h>

int main()
{

int DSLength = GetLogicalDriveStrings(0,NULL);

//通过GetLogicalDriveStrings()函数获取所有驱动器字符串信息长度。

char* DStr = new char[DSLength];//用获取的长度在堆区创建一个c风格的字符串数组

GetLogicalDriveStrings(DSLength,(LPTSTR)DStr);

//通过GetLogicalDriveStrings将字符串信息复制到堆区数组中,其中保存了所有驱动器的信息。

int DType;
int si=0;

for(int i=0;i<DSLength/4;++i)

//为了显示每个驱动器的状态,则通过循环输出实现,由于DStr内部保存的数据是A:\NULLB:\NULLC:\NULL,这样的信息,所以DSLength/4可以获得具体大循环范围

{

char dir[3]={DStr[si],':','\\'};

//cout<<dir;

DType = GetDriveType((LPCWSTR)DStr+i*4);

//GetDriveType函数,可以获取驱动器类型,参数为驱动器的根目录

if(DType == DRIVE_FIXED)

{
printf("%c",*dir);

printf("硬盘\n");

}
si+=4;

}
system("pause");//

return 1;
}

⑸ C语言知道经纬度求两地距离的题目,求高手指点哪里错了,对了再加分

最后的计算s的公式有问题,因为反余弦函数y=arccosx中,y的取值范围只能是-π/2 ≤ y ≤ π/2,而地球上两点间的夹角明显在0到180°之间,所以这个地方你还应该加上角度判断语句,另外你的R的单位是km,最后的结果页应该是km。

⑹ 已知某地点的精度λ,试求它所在的6°带与3°的带号及中央子午线的经度是多少

若已知某点的经度为λ,则该点的6º带的带号N由下式计算:

N=int(λ/6)+1 (int为取整的意思)
中央子午线经度 Ln=6°N-3°

若已知某点的经度为L,则该点所在3º带的带号按下式计算:

n=L/3 (四舍五入)
中央子午线经度 Ln=3°n

⑺ c语言设计问题

#include<stdio.h>

#include<math.h>

#definePI3.141592

main()

{

doublea,b,c,d,s,r; /*a表示纬度,bc表示经度*/

r=6371.00;

printf("请输入纬度a=");

scanf("%lf",&a);

d=cosh(a)*r; /*d表示此纬度上的半径*/

printf("请输入两地经度(东经为正,西经为负)b=,c=");

scanf("%lf%lf",&b,&c);//加了,

s=fabs(b-c)/360*2*PI*d;

printf("%lf",s);

}

//我把%f改成了%lf

//你运行一下试一试

//怎么,有什么问题

⑻ C语言中怎么表示经纬度呢

提供一思路,仅参考:
参照坐标系点的表示法
a(x,y)

⑼ 求解C语言编程

已知两地的经度分别为σ1、σ2,纬度分别为φ1、φ2,求两地最近距离的公式为:
S=2πRθ/360° (1)
其中θ可由下面的式子求得:
[sin(θ/2)]^2=[sin(φ1-φ2)/2]^2+[sin(σ2-σ1)/2]^2cosφ1cosφ2 (2)
注:1、式中S为球面上任意两点的最短距离(球面距离);
2、θ为两点间的张角,在运用(2)式求θ时,纬度φ和经度σ本身有正负号,通常北纬正,南纬负;东经正,西经负。
3、因不会用上下标,所以式中^2指平方; cosφ1cosφ2、σ2-σ1 、φ1-φ2中的1和和2为下标。
我想你的问题是不知道公式,知道公式后就是C语言做个算术题,这个不用我教了吧。

⑽ 利用日期、经纬度求日出日落时间 C语言程序代码

#definePI3.1415926

#include<math.h>

#include<iostream>

usingnamespacestd;


intdays_of_month_1[]={31,28,31,30,31,30,31,31,30,31,30,31};

intdays_of_month_2[]={31,29,31,30,31,30,31,31,30,31,30,31};

longdoubleh=-0.833;

//定义全局变量


voidinput_date(intc[]){

inti;

cout<<"Enterthedate(form:20090310):"<<endl;

for(i=0;i<3;i++){

cin>>c[i];

}

}

//输入日期


voidinput_glat(intc[]){

inti;

cout<<"Enterthedegreeoflatitude(range:0°-60°,form:404040(means40°40′40″)):"<<endl;

for(i=0;i<3;i++){

cin>>c[i];

}

}

//输入纬度


voidinput_glong(intc[]){

inti;

cout<<"Enterthedegreeoflongitude(westisnegativ,form:404040(means40°40′40″)):"<<endl;

for(i=0;i<3;i++){

cin>>c[i];

}

}

//输入经度


intleap_year(intyear){

if(((year%400==0)||(year%100!=0)&&(year%4==0)))return1;

elsereturn0;

}

//判断是否为闰年:若为闰年,返回1;若非闰年,返回0


intdays(intyear,intmonth,intdate){

inti,a=0;

for(i=2000;i<year;i++){

if(leap_year(i))a=a+366;

elsea=a+365;

}

if(leap_year(year)){

for(i=0;i<month-1;i++){

a=a+days_of_month_2[i];

}

}

else{

for(i=0;i<month-1;i++){

a=a+days_of_month_1[i];

}

}

a=a+date;

returna;

}

//求从格林威治时间公元2000年1月1日到计算日天数days


longdoublet_century(intdays,longdoubleUTo){

return((longdouble)days+UTo/360)/36525;

}

//求格林威治时间公元2000年1月1日到计算日的世纪数t


longdoubleL_sun(longdoublet_century){

return(280.460+36000.770*t_century);

}

//求太阳的平黄径


longdoubleG_sun(longdoublet_century){

return(357.528+35999.050*t_century);

}

//求太阳的平近点角


longdoubleecliptic_longitude(longdoubleL_sun,longdoubleG_sun){

return(L_sun+1.915*sin(G_sun*PI/180)+0.02*sin(2*G_sun*PI/180));

}

//求黄道经度


longdoubleearth_tilt(longdoublet_century){

return(23.4393-0.0130*t_century);

}

//求地球倾角


longdoublesun_deviation(longdoubleearth_tilt,longdoubleecliptic_longitude){

return(180/PI*asin(sin(PI/180*earth_tilt)*sin(PI/180*ecliptic_longitude)));

}

//求太阳偏差


longdoubleGHA(longdoubleUTo,longdoubleG_sun,longdoubleecliptic_longitude){

return(UTo-180-1.915*sin(G_sun*PI/180)-0.02*sin(2*G_sun*PI/180)+2.466*sin(2*ecliptic_longitude*PI/180)-0.053*sin(4*ecliptic_longitude*PI/180));

}

//求格林威治时间的太阳时间角GHA


longdoublee(longdoubleh,longdoubleglat,longdoublesun_deviation){

return180/PI*acos((sin(h*PI/180)-sin(glat*PI/180)*sin(sun_deviation*PI/180))/(cos(glat*PI/180)*cos(sun_deviation*PI/180)));

}

//求修正值e


longdoubleUT_rise(longdoubleUTo,longdoubleGHA,longdoubleglong,longdoublee){

return(UTo-(GHA+glong+e));

}

//求日出时间


longdoubleUT_set(longdoubleUTo,longdoubleGHA,longdoubleglong,longdoublee){

return(UTo-(GHA+glong-e));

}

//求日落时间


longdoubleresult_rise(longdoubleUT,longdoubleUTo,longdoubleglong,longdoubleglat,intyear,intmonth,intdate){

longdoubled;

if(UT>=UTo)d=UT-UTo;

elsed=UTo-UT;

if(d>=0.1){

UTo=UT;

UT=UT_rise(UTo,GHA(UTo,G_sun(t_century(days(year,month,date),UTo)),ecliptic_longitude(L_sun(t_century(days(year,month,date),UTo)),G_sun(t_century(days(year,month,date),UTo)))),glong,e(h,glat,sun_deviation(earth_tilt(t_century(days(year,month,date),UTo)),ecliptic_longitude(L_sun(t_century(days(year,month,date),UTo)),G_sun(t_century(days(year,month,date),UTo))))));

result_rise(UT,UTo,glong,glat,year,month,date);

}

returnUT;

}

//判断并返回结果(日出)


longdoubleresult_set(longdoubleUT,longdoubleUTo,longdoubleglong,longdoubleglat,intyear,intmonth,intdate){

longdoubled;

if(UT>=UTo)d=UT-UTo;

elsed=UTo-UT;

if(d>=0.1){

UTo=UT;

UT=UT_set(UTo,GHA(UTo,G_sun(t_century(days(year,month,date),UTo)),ecliptic_longitude(L_sun(t_century(days(year,month,date),UTo)),G_sun(t_century(days(year,month,date),UTo)))),glong,e(h,glat,sun_deviation(earth_tilt(t_century(days(year,month,date),UTo)),ecliptic_longitude(L_sun(t_century(days(year,month,date),UTo)),G_sun(t_century(days(year,month,date),UTo))))));

result_set(UT,UTo,glong,glat,year,month,date);

}

returnUT;

}

//判断并返回结果(日落)


intZone(longdoubleglong){

if(glong>=0)return(int)((int)(glong/15.0)+1);

elsereturn(int)((int)(glong/15.0)-1);

}

//求时区


voidoutput(longdoublerise,longdoubleset,longdoubleglong){

if((int)(60*(rise/15+Zone(glong)-(int)(rise/15+Zone(glong))))<10)

cout<<"Thetimeatwhichthesunrisesis"<<(int)(rise/15+Zone(glong))<<":0"<<(int)(60*(rise/15+Zone(glong)-(int)(rise/15+Zone(glong))))<<". ";

elsecout<<"Thetimeatwhichthesunrisesis"<<(int)(rise/15+Zone(glong))<<":"<<(int)(60*(rise/15+Zone(glong)-(int)(rise/15+Zone(glong))))<<". ";

if((int)(60*(set/15+Zone(glong)-(int)(set/15+Zone(glong))))<10)

cout<<"Thetimeatwhichthesunsetsis"<<(int)(set/15+Zone(glong))<<":"<<(int)(60*(set/15+Zone(glong)-(int)(set/15+Zone(glong))))<<". ";

elsecout<<"Thetimeatwhichthesunsetsis"<<(int)(set/15+Zone(glong))<<":"<<(int)(60*(set/15+Zone(glong)-(int)(set/15+Zone(glong))))<<". ";

}

//打印结果intmain(){

longdoubleUTo=180.0;

intyear,month,date;

longdoubleglat,glong;

intc[3];

input_date(c);

year=c[0];

month=c[1];

date=c[2];

input_glat(c);

glat=c[0]+c[1]/60+c[2]/3600;

input_glong(c);

glong=c[0]+c[1]/60+c[2]/3600;

longdoublerise,set;

rise=result_rise(UT_rise(UTo,GHA(UTo,G_sun(t_century(days(year,month,date),UTo)),ecliptic_longitude(L_sun(t_century(days(year,month,date),UTo)),G_sun(t_century(days(year,month,date),UTo)))),glong,e(h,glat,sun_deviation(earth_tilt(t_century(days(year,month,date),UTo)),ecliptic_longitude(L_sun(t_century(days(year,month,date),UTo)),G_sun(t_century(days(year,month,date),UTo)))))),UTo,glong,glat,year,month,date);

set=result_set(UT_set(UTo,GHA(UTo,G_sun(t_century(days(year,month,date),UTo)),ecliptic_longitude(L_sun(t_century(days(year,month,date),UTo)),G_sun(t_century(days(year,month,date),UTo)))),glong,e(h,glat,sun_deviation(earth_tilt(t_century(days(year,month,date),UTo)),ecliptic_longitude(L_sun(t_century(days(year,month,date),UTo)),G_sun(t_century(days(year,month,date),UTo)))))),UTo,glong,glat,year,month,date);

output(rise,set,glong);

system("pause");

return0;

}