Advertisement
dllbridge

Untitled

Sep 13th, 2024
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.88 KB | None | 0 0
  1.  
  2.  
  3.  
  4. #include <stdio.h>
  5.  
  6. int foo(int&p);
  7.  
  8. ///////////////////////////////////////////
  9. int main()
  10. {
  11.    
  12.     int mas[99] = {10,20,40,55};
  13.    
  14.     int &r1 = mas[1];      ///  int &r1 = mas[2];  DZ
  15.    
  16.     printf("%d\n", foo(r1));
  17. }
  18.  
  19.  
  20. ///////////////////////////////////////////   125
  21. int foo(int &r2)
  22. {
  23.    
  24.     int nSum = 0;
  25.    
  26.         nSum += r2;
  27.        
  28.     int *p = &r2;  
  29.    
  30.         nSum += p[ 1];
  31.         nSum += p[ 2];        
  32.         nSum += p[-1];    
  33.        
  34. return nSum;                 //   125
  35. }
  36.  
  37.  
  38.  
  39.  
  40.  
  41.  
  42.  
  43.  
  44.  
  45.  
  46.  
  47.  
  48.  
  49.  
  50.  
  51.  
  52.  
  53.  
  54.  
  55.  
  56.  
  57.  
  58.  
  59.  
  60.  
  61.  
  62.  
  63.  
  64.  
  65. /*
  66.  
  67. #include <stdio.h>
  68.  
  69.  
  70. ////////////////////////////////////
  71. int main()
  72. {
  73.    
  74.     int nArr[5] = {10, 11, 12, 13, 14};
  75.    
  76.     int* p = &nArr[2];
  77.    
  78.     int &p1 = *p;
  79.  
  80.     printf("%d\n%d\n   ", *p, p1);
  81. }
  82.  
  83.  
  84. */
  85.  
  86.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement