Advertisement
myloyo

8.4.15

Mar 2nd, 2023 (edited)
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.61 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. float F(float x) {
  6.     if (x - 1 == 1) {
  7.         return 0;
  8.     }
  9.     else if (x - 1 < 1) {
  10.         return 1;
  11.     }
  12.     else if (x - 1 > 1) {
  13.         return -1;
  14.     }
  15. }
  16.  
  17. void F(float x, float& y) {
  18.     if (x - 1 == 1) {
  19.         y = 0;
  20.         cout << y;
  21.     }
  22.     else if (x - 1 < 1) {
  23.         y = 1;
  24.         cout << y;
  25.     }
  26.     else if (x - 1 > 1) {
  27.         y = -1;
  28.         cout << y;
  29.     }
  30. }
  31.  
  32. int main() {
  33.     for (float i = 1.0; i < 4; i++) {
  34.         cout << F(i) << " ";
  35.         float y = 0;
  36.         F(i, y);
  37.         cout << endl;
  38.     }
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement