Advertisement
Guest User

Прога

a guest
Dec 2nd, 2016
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.16 KB | None | 0 0
  1. #include <iostream>
  2. #include <ctime>
  3. using namespace std;
  4.  
  5. int nod(int a, int b) {
  6.     while (a != b)
  7.         a > b ? a -= b : b -= a;
  8.     return a;
  9. }
  10.  
  11. int main(){
  12.     setlocale(0, "");
  13.  
  14.     srand(time(NULL));
  15.  
  16.     int a1 = rand() % 10000 + 1;
  17.     int b1 = rand() % 10000 + 1;
  18.     int c1 = rand() % 10000 + 1;
  19.     int d1 = rand() % 10000 + 1;
  20.     int a2 = rand() % 10000 + 1;
  21.     int b2 = rand() % 10000 + 1;
  22.     int c2 = rand() % 10000 + 1;
  23.     int d2 = rand() % 10000 + 1;
  24.     int x0 = rand() % 10000 + 1;
  25.     int y0 = rand() % 10000 + 1;
  26.     int z0 = rand() % 10000 + 1;
  27.  
  28.     cout << a1 << " " << b1 << " " << c1 << " " << d1 << " " << a2 << " " << b2 << " " << c2 << " " << d2  << " " << x0 << " " << y0 << " " << z0 << endl;
  29.  
  30.     long long lambda = ((a1 * x0 + b1 * y0 + c1 * z0 + d1) / (a2 * x0 + b2 * y0 + c2 * z0 + d2)) * (-1);
  31.     cout << lambda << endl;
  32.  
  33.     int A = 2 * (a1 + lambda * a2);
  34.     int B = 2 * (b1 + lambda * b2);
  35.     int C = 2 * (c1 + lambda * c2);
  36.     int D = 2 * (d1 + d2);
  37.  
  38.     cout << A << " " << B << " " << C << " " << D << endl;
  39.  
  40.     int n = nod(((A, B), C), D);
  41.     cout << n << endl;
  42.  
  43.     cout << A / n << " " << B / n << " " << C / n << " " << D / n << endl;
  44.  
  45.     system("pause");
  46.     return 0;
  47. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement