用Fortran语言编写:已知U,V风速,判断风向实习资料:U,V风速由键盘任意输入
时间: 2023-05-10 15:56:09 浏览: 223
以下是用Fortran语言编写的代码,可以根据输入的U和V风速来判断风向:
```
program wind_direction
implicit none
real :: u, v, angle
write(*,*) '请输入U风速:'
read(*,*) u
write(*,*) '请输入V风速:'
read(*,*) v
angle = atan2(v, u) * 180 / 3.1415926
if (angle < 0) then
angle = angle + 360
endif
if (angle >= 337.5 .or. angle < 22.5) then
write(*,*) '风向为:正北'
else if (angle >= 22.5 .and. angle < 67.5) then
write(*,*) '风向为:东北'
else if (angle >= 67.5 .and. angle < 112.5) then
write(*,*) '风向为:正东'
else if (angle >= 112.5 .and. angle < 157.5) then
write(*,*) '风向为:东南'
else if (angle >= 157.5 .and. angle < 202.5) then
write(*,*) '风向为:正南'
else if (angle >= 202.5 .and. angle < 247.5) then
write(*,*) '风向为:西南'
else if (angle >= 247.5 .and. angle < 292.5) then
write(*,*) '风向为:正西'
else if (angle >= 292.5 .and. angle < 337.5) then
write(*,*) '风向为:西北'
endif
end program wind_direction
```
希望这个代码能够帮助你解决问题!
阅读全文