read(*,*)c
program main
implicit none
type::rational !分数类型
integer :: num !分子
integer :: denom !分母
end type
type(rational)::temp
complex::c
read(*,*)c !读取复数 例如(1.0,2.0)
temp%num = nint(real(c)) !取实部最接近整数
temp%denom = nint(aimag(c)) !取虚部最接近整数
write(*,*)temp
read(*,*)
end program
Non-Default-Derived-Type-IO.pdf
180.07 KB, 下载次数: 4
欢迎光临 Fortran Coder (http://bbs.fcode.cn/) | Powered by Discuz! X3.2 |