orthog.f
来自「Fortran的数学物理方程数值算法源程序。这是"Numerical Metho」· F 代码 · 共 35 行
F
35 行
! orthog - Program to test if a pair of vectors! is orthogonal. Assumes vectors are in 3D space program orthog !* Initialize the vectors a and b integer*4 i real*8 a(3), b(3), a_dot_b write(*,*) 'Enter the first vector' do i=1,3 write(*,*) ' a(', i, ') = ' read(*,*) a(i) enddo write(*,*) 'Enter the second vector' do i=1,3 write(*,*) ' b(', i, ') = ' read(*,*) b(i) enddo !* Evaluate the dot product as sum over products of elements a_dot_b = 0.0 do i=1,3 a_dot_b = a_dot_b + a(i)*b(i) enddo !* Print dot product and state whether vectors are orthogonal if( a_dot_b .eq. 0.0 ) then write(*,*) 'Vectors are orthogonal' else write(*,*) 'Vectors are NOT orthogonal' write(*,*) 'Dot product = ', a_dot_b endif stop end
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?