program ex
implicit none
character(len=50)input,output
integer i,strlen
integer::j=1
write(*,*)"请输入字符串"
read (*,"(A50)")input
strlen=len_trim(input)
do i=1,strlen
if (input(i:i)/=' ')then
output(j:j)=input(i:i)
j=j+1
end if
end do
write(*,"(A50)")output
end