• API
• FAQ
• Tools
• Archive
daily pastebin goal
20%
SHARE
TWEET

# Untitled

a guest Feb 20th, 2019 73 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
1. #include "stdafx.h"
2. #include <stdlib.h>
3. #include <iostream>
4. #include <conio.h>
5. #include <math.h>
6. using namespace std;
7.
8. int f(int& a, int& b, int x, int y); // по значению
9.
10. int ff(int& a, int& b, int &x, int &y) // со ссылке
11. {
12.     if(y == 0)
13.     {
14.         return 0;
15.     }
16.
17.     a = x*y;
18.     b = x/y;
19.
20.     return 1;
21. }
22.
23. int f(int& a, int& b, int *x, int *y) // со указателю
24. {
25.     if((*y) == 0)
26.     {
27.         return 0;
28.     }
29.
30.     a = (*x)*(*y);
31.     b = (*x)/(*y);
32.
33.     return 1;
34. }
35.
36. int main()
37. {
38.     setlocale(LC_ALL, "Russian");
39.
40.     int a = 10;
41.     int b = 5;
42.
43.     cout << "Начальные a = " << a << ", b = " << b << endl;
44.     cout << "передача x, y по значению - return: " << f(a, b, 21, 7) << endl;
45.     cout << "a = " << a << endl;
46.     cout << "b = " << b << endl;
47.
48.     int x = 24;
49.     int y = 4;
50.     cout << "передача x, y по ссылке - return: " << ff(a, b, x, y) << endl;
51.     cout << "a = " << a << endl;
52.     cout << "b = " << b << endl;
53.
54.     x = 16;
55.     y = 0;
56.     cout << "передача x, y по указателю - return: " << f(a, b, &x, &y) << endl;
57.     cout << "a = " << a << endl;
58.     cout << "b = " << b << endl;
59.
60.     getch();
61.
62.     return 0;
63. }
64.
65. int f(int& a, int& b, int x, int y)
66. {
67.     if(y == 0)
68.     {
69.         return 0;
70.     }
71.
72.     a = x*y;
73.     b = x/y;
74.
75.     return 1;
76. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy.

Top