- 字符串'500' 转换为整型500;
- 整型500转换为字符型'500';
- 浮点型500.00转换为字符型;
1. 字符型转换为整型
例:'500'----->500
character(len=30) :: a
integer b
a='500'
read(a,*)b
write(*,'(I3)')b
2. 字符型转化为浮点型
例:'500.00'---->500.00
character(len=30) :: a
real b
a='500.00'
read(a,*)b
write(*,'(F6.2)')b
3. 整型转换为字符型
例:500----->'500'
character(len=3) :: a
integer b
b=500
write(a,'(I3)')b
write(*,*)a
4. 浮点型转换为字符型
例:500.13----->'500.13'
character(len=6) :: a
real b
b=500.13
write(a,'(F6.2)')b
write(*,*)a
没有评论:
发表评论