⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 orthog.cpp

📁 c++的数学物理方程数值算法源程序。这是"Numerical Methods for Physics"第二版的源程序。
💻 CPP
字号:
// orthog - Program to test if a pair of vectors // is orthogonal.  Assumes vectors are in 3D space#include <iostream.h>
void main() {  //* Initialize the vectors a and b  double a[3+1], b[3+1];
  cout << "Enter the first vector" << endl;  int i;
  for( i=1; i<=3; i++ ) {    cout << "  a[" << i << "] = ";    cin >> a[i];  }  cout << "Enter the second vector" << endl;  for( i=1; i<=3; i++ ) {    cout << "  b[" << i << "] = ";    cin >> b[i];  }  //* Evaluate the dot product as sum over products of elements  double a_dot_b = 0.0;  for( i=1; i<=3; i++ )    a_dot_b += a[i]*b[i];  //* Print dot product and state whether vectors are orthogonal  if( a_dot_b == 0.0 )    cout << "Vectors are orthogonal" << endl;  else {    cout << "Vectors are NOT orthogonal" << endl;    cout << "Dot product = " << a_dot_b << endl;  }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -