Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- 8. Dane są dwa wektory liczb rzeczywistych. Napisz program, który oblicza iloczyn wektorowy.
- */
- #include <cstdlib>
- #include <iostream>
- #include <cmath>
- #include <ctime>
- using namespace std;
- int wektorowy(float a[],float b[])
- {
- cout<<"A: "<<endl;
- for (int i=0;i<3;i++)
- {
- a[i]=1+( float ) rand() / RAND_MAX *( 8 );
- cout<<a[i]<<endl;
- }
- cout<<"B: "<<endl;
- for (int i=0;i<3;i++)
- {
- b[i]=1+( float ) rand() / RAND_MAX *( 8 );
- cout<<b[i]<<endl;
- }
- float c1,c2,c3;
- c1=a[1]*b[2]-a[2]*b[1];
- c2=a[2]*b[0]-a[0]*b[2];
- c3=a[0]*b[1]-a[1]*b[0];
- cout<<"A*B= "<<c1<<" "<<c2<<" "<<c3<<endl;
- }
- int main()
- {
- srand(time(NULL));
- float a[3],b[3];
- wektorowy(a,b);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment