Kalkulator wektorów

 

#include <iostream>

//Aleksandra Zuziak

/* run this program using the console pauser or add your own getch, system("pause") or input loop */

 using namespace std;

int main(int argc, char** argv) 

int u[2],v[2];

    cout<<"Podaj wspolrzedne pierwszego wektora "<<endl;

cin>>u[0]>>u[1];

cout<<"Podaj wspolrzedne drugiego wektora "<<endl;

cin>>v[0]>>v[1];

cout<<"u=["<<u[0]<<","<<u[1]<<"]"<<endl;

cout<<"v=["<<v[0]<<","<<v[1]<<"]"<<endl;

cout<<"u+v=["<<u[0]+v[0]<<","<<u[1]+v[1]<<"]"<<endl;

cout<<"u-v=["<<u[0]-v[0]<<","<<u[1]-v[1]<<"]"<<endl;

cout<<"Podaj a "<<endl;

float a;

cin>>a;

cout<<"a*u=["<<a*u[0]<<","<<a*u[1]<<"]"<<endl;

cout<<"u*v="<<u[0]*v[0]+u[1]*v[1]<<endl;

float b;

b=u[0]*v[0]+u[1]*v[1];

if(b==0)

cout<<"Wektory sa prostopadle"<<endl;

else

cout<<"Wektory nie sa prostopadle"<<endl;

return 0;
}