找不到fortran代码中存在的问题
implicit none
integer :: i
character(len = 20) ::str1
character(len = 20) ::str1a
character(len = 20) ::str2
character(len = 20) ::str2a
write(*,*)"enter the first string to compare:"
read(*,*)str1
write(*,*)"enter the second string to compare:"
read(*,*)str2
str1a = str1
str2a = str2
do i = 1,len(str1a)
if(str1a(i:i) >= 'a '.and. str1a(i:i) <= 'z')then
str1a(i:i) = achar(iachar(str1a(i:i)) - 32)
end if
end do
do i = 1,len(str2a)
if(str2a(i:i) >= 'a '.and. str2a(i:i) <= 'z')then
str2a(i:i) = achar(iachar(str2a(i:i)) - 32)
end if
end do
if(str1a == str2a)then
write(*,*)"'",str1,"'"," = ",str2,"ignoring case."
else
write(*,*)"'",str1,"'","/ = ",str2,"ignoring case."
end if
end
数组是一组类型完全相同、且用单个名字来引用的变量或常量。
代码没问题。