Advertisement
PiotrJurek

Zad14

Mar 29th, 2020
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.62 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. // Funkcja nie moze zwracac dwoch zmiennych jak jest w poleceniu,
  6. // wiec zrobilem to posylajac voidowi oryginalne zmienne
  7.  
  8. void ZAMIANA(float &a, float &b)
  9. {
  10. float bufor;
  11. bufor = a;
  12. a = b;
  13. b = bufor;
  14. }
  15.  
  16. int main()
  17. {
  18. float a = 5;
  19. float b = 8;
  20. ZAMIANA(a, b);
  21. cout << a << endl;
  22. cout << b << endl;
  23.  
  24. float c = -10;
  25. float d = 0;
  26. ZAMIANA(c, d);
  27. cout << c << endl;
  28. cout << d << endl;
  29.  
  30. float e = 3.1415;
  31. float f = 999;
  32. ZAMIANA(e, f);
  33. cout << e << endl;
  34. cout << f << endl;
  35.  
  36. return 0;
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement