[Fortran] 纯文本查看 复制代码
program ex0611
implicit none
integer i
integer strlen
integer,parameter::key =2
character (len =20)::string
write (*,*)"String"
read (*,*)string
strlen =len_trim(string)
do i =1,strlen
string (i:i)=char (ichar(string(i:i))+key)
end do
write (*,"('Encoded:',a20)")string
stop
end
[Fortran] 纯文本查看 复制代码
program ex0611
implicit none
integer i
integer strlen
integer,parameter::key =2
character (len =20)::string
write (*,*)"String"
read (*,'(a20)')string !// 修改此句
strlen =len_trim(string)
do i =1,strlen
string (i:i)=char (ichar(string(i:i))+key)
end do
write (*,"('Encoded:',a20)")string
stop
end