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

📄 pex6_5.cpp

📁 数据结构C++代码,经典代码,受益多多,希望大家多多支持
💻 CPP
字号:
#include <iostream.h>
#pragma hdrstop

#include "wex6_12.h"

void main(void)
{
	Vec2d u(1,1), v(3,5), w(2,7);
	float x,y;

	// print u,v,w and illustrate the distributive law
	// for vectors
	cout << "u = " << u << "  v = "
		 << v << "  w = " << w << endl;
	cout << "u*(v+w) = " << (u*(v+w)) << endl;
	cout << "u*v + u*w = " << (u*v + u*w) << endl;
	
	// illustrate the commutativity of scalar multiplication
	cout << "5*v = " << 5*v << endl;
	cout << "v*5 = " << v*5 << endl;
	
	cout << "Enter two floating point numbers x and y: ";
	cin >> x >> y;
	
	// the vectors x1 and x2 are perpendicular
	Vec2d x1(x,y), x2(-y,x);

	// verify that the dot product x1*x2 is 0
	cout << x1 << '*' << x2 << " = " << x1*x2 << endl;
	cout << endl;
}
/*
<Run>

u = (1,1)  v = (3,5)  w = (2,7)
u*(v+w) = 17
u*v + u*w = 17
5*v = (15,25)
v*5 = (15,25)
Enter two floating point numbers x and y: 3 5
(3,5)*(-5,3) = 0
*/

⌨️ 快捷键说明

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