fork download
  1. #include <iostream>
  2. #include <vector>
  3. #include <algorithm>
  4.  
  5. using namespace std;
  6.  
  7.  
  8. // Перераспределить значения переменных
  9. void Pr(double &x, double &y, double &z)
  10. {
  11. std::vector<double> v;
  12.  
  13. v.push_back(x);
  14. v.push_back(y);
  15. v.push_back(z);
  16.  
  17. std::sort ( v.begin(), v.end() );
  18.  
  19. x = v[0];
  20. y = v[1];
  21. z = v[2];
  22. }
  23.  
  24.  
  25.  
  26. int main()
  27. {
  28. double x=7, y=1, z=4;
  29.  
  30. cout << "x=" << x << endl;
  31. cout << "y=" << y << endl;
  32. cout << "z=" << z << endl;
  33.  
  34. Pr(x, y, z);
  35.  
  36. cout << "x=" << x << endl;
  37. cout << "y=" << y << endl;
  38. cout << "z=" << z << endl;
  39.  
  40. return 0;
  41. }
Success #stdin #stdout 0s 15240KB
stdin
Standard input is empty
stdout
x=7
y=1
z=4
x=1
y=4
z=7