Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- int foo(int&p);
- ///////////////////////////////////////////
- int main()
- {
- int mas[99] = {10,20,40,55};
- int &r1 = mas[1]; /// int &r1 = mas[2]; DZ
- printf("%d\n", foo(r1));
- }
- /////////////////////////////////////////// 125
- int foo(int &r2)
- {
- int nSum = 0;
- nSum += r2;
- int *p = &r2;
- nSum += p[ 1];
- nSum += p[ 2];
- nSum += p[-1];
- return nSum; // 125
- }
- /*
- #include <stdio.h>
- ////////////////////////////////////
- int main()
- {
- int nArr[5] = {10, 11, 12, 13, 14};
- int* p = &nArr[2];
- int &p1 = *p;
- printf("%d\n%d\n ", *p, p1);
- }
- */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement