Psst.. new poll here.
Psst.. new forums here.
Microsoft is blocking us again (TY IP Reputation!) so just use oauth login instead. :)
Paste
Pasted as C++ by xyz ( 17 years ago )
#include <cstdlib>
#include <iostream>
#include <cmath>
using namespace std;
int main(int argc, char *argv[])
{
float dlugosc1, dlugosc2;
int m, a;
float kat;
float suma;
int x, y;
cout<<"podaj liczbe wymiarów";
cin>>m;
int wektor1[m], wektor2[m];
dlugosc1 = 0;
dlugosc2 = 0;
kat = 0;
for(a=1; a<=m; a=a+1){
cout<<" wspolrzedna 1 wektora";
cin>>wektor1[a];
dlugosc1 += wektor1[a]*wektor1[a];
}
cout<<"dlugosc wektora 1 to:"<<sqrt(dlugosc1)<<endl;
for(a=1; a<=m; a=a+1){
cout<<" wspolrzedna 2 wektora";
cin>>wektor2[a];
dlugosc2 += wektor2[a]*wektor2[a];
}
cout<<"dlugosc wektora 2 to:"<<sqrt(dlugosc2)<<endl;
for(a=1; a<=m; a=a+1){
kat += wektor2[a]*wektor1[a];
}
kat = (acos(kat/(sqrt(dlugosc1)*sqrt(dlugosc2))/3.14)*180);
cout<<"kat pomiedzy wektorami wynosi:"<<kat<<" stopni"<<endl;
for(a=1; a<=m; a=a+1){
suma += (wektor2[a]/sqrt(dlugosc2))*wektor1[a];
}
for(a=1; a<=m; a=a+1){
x = suma*(wektor2[a]/sqrt(dlugosc2));
cout<<"wspolrzedna wektora rownoleglego:"<<x<<endl;
}
for(a=1; a<=m; a=a+1){
y = wektor1[a]-x;
cout<<"wspolrzedna wektora prostopadlego"<<y<<endl;
}
system("PAUSE");
return EXIT_SUCCESS;
}
Revise this Paste