[Fortran] 纯文本查看 复制代码 program main
implicit none
!自定义类型
type distance
real::m,cm,inch
end type
!申明自定义类型
type(distance)::a
write(*,*)"输入公尺(m)"
read(*,*)a%m
a%cm=a%m*100
a%inch=a%m*39.3700787
write(*,*)a%m,"m"
write(*,*)a%cm,"cm"
write(*,*)a%inch,"inch"
end program
1.创建自定义类型必须包含在
[Fortran] 纯文本查看 复制代码
type
end type
2.自定义类型中元素的访问需要用% |