PatrickSwayze

zad 8lab10

Jan 10th, 2018
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.78 KB | None | 0 0
  1. /*
  2. 8. Dane są dwa wektory liczb rzeczywistych. Napisz program, który oblicza iloczyn wektorowy.
  3. */
  4. #include <cstdlib>
  5. #include <iostream>
  6. #include <cmath>
  7. #include <ctime>
  8. using namespace std;
  9.  
  10. int wektorowy(float a[],float b[])
  11. {
  12.     cout<<"A: "<<endl;
  13.     for (int i=0;i<3;i++)
  14.     {
  15.         a[i]=1+( float ) rand() / RAND_MAX *( 8 );
  16.         cout<<a[i]<<endl;
  17.     }
  18.     cout<<"B: "<<endl;
  19.     for (int i=0;i<3;i++)
  20.     {
  21.         b[i]=1+( float ) rand() / RAND_MAX *( 8 );
  22.         cout<<b[i]<<endl;
  23.     }
  24.     float c1,c2,c3;
  25.     c1=a[1]*b[2]-a[2]*b[1];
  26.     c2=a[2]*b[0]-a[0]*b[2];
  27.     c3=a[0]*b[1]-a[1]*b[0];
  28.     cout<<"A*B= "<<c1<<" "<<c2<<" "<<c3<<endl;
  29.  
  30. }
  31.  
  32. int main()
  33. {
  34.  
  35.     srand(time(NULL));
  36.  
  37.     float a[3],b[3];
  38.     wektorowy(a,b);
  39.  
  40.  
  41.   return 0;
  42. }
Advertisement
Add Comment
Please, Sign In to add comment