3.编写一个程序,要求用户以度、分、秒的方式输入一个纬度,然后以度为单位显示该纬度。1度为 60分,1分等于60秒,请以符号常量的方式表示这些值。对于每个输入值,应使用一个独立的变量存储它。ド面是该程序运行时的情况: Enter a latitude in degrees,minutes, and seconds: First, enter the degrees:37 Next,enter the minutesofarc:51 Finally, enter the seconds ofarc:19 37 degrees,51 minutes19 seconds=37.8553 degrees
时间: 2023-05-26 10:06:24 浏览: 73
#include <stdio.h>
#define MIN_PER_DEG 60 // 每度的分钟数
#define SEC_PER_MIN 60 // 每分钟的秒数
int main(void)
{
int degrees, minutes, seconds;
double decimal_degrees;
printf("Enter a latitude in degrees, minutes, and seconds:\n");
printf("First, enter the degrees: ");
scanf("%d", °rees);
printf("Next, enter the minutes of arc: ");
scanf("%d", &minutes);
printf("Finally, enter the seconds of arc: ");
scanf("%d", &seconds);
// 将输入的纬度转换为十进制度数
decimal_degrees = (double)degrees + (double)minutes / MIN_PER_DEG + (double)seconds / (MIN_PER_DEG * SEC_PER_MIN);
printf("%d degrees, %d minutes, %d seconds = %.4f degrees\n", degrees, minutes, seconds, decimal_degrees);
return 0;
}
相关推荐
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)