Advertisement
dllbridge

Untitled

Apr 16th, 2023
798
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.13 KB | None | 0 0
  1.  
  2.  
  3. #include <iostream>
  4. #include <stdio.h>
  5. #include <stdlib.h>
  6. #include <time.h>
  7.  
  8. using namespace std;
  9.  
  10. void foo(int &);
  11.  
  12. int main () {
  13.     int nCount = 20,
  14.         nArr[20]   ;
  15.    
  16.     for (int i = 0; i < nCount; i++) {
  17.         nArr[i] = rand()%1000;
  18.         cout << nArr[i] << endl;
  19.     }
  20.    
  21.     foo(nArr[11]); //?     
  22. }
  23.  
  24.  
  25.  
  26. /////////////////////////////////////////////////////////
  27. void foo(int &Arr)                                     //  
  28. {
  29.     cout << "------" << endl;
  30.  
  31.     int *p = &Arr;
  32.    
  33.     int *p2 = p -= 11;   
  34.    
  35.     for(int i = 0; i < 20; i++) {
  36.    
  37.         cout << p[i] << endl;
  38.     }
  39. }
  40.  
  41.  
  42. /*
  43. #include <iostream>
  44. #include <stdio.h>
  45. #include <stdlib.h>
  46. #include <time.h>
  47.  
  48. using namespace std;
  49.  
  50. void foo(int *Arr);
  51.  
  52. int main () {
  53.     int nCount = 20,
  54.         nArr[20]   ;
  55.    
  56.     for (int i = 0; i < nCount; i++) {
  57.         nArr[i] = rand()%1000;
  58.         cout << nArr[i] << endl;
  59.     }
  60.    
  61.     foo(&nArr[11]); //?    
  62. }
  63.  
  64.  
  65.  
  66. /////////////////////////////////////////////////////////
  67. void foo(int *Arr)                                     //  
  68. {
  69.     cout << "------" << endl;
  70.  
  71.     int *p = Arr -= 11;  
  72.    
  73.     for(int i = 0; i < 20; i++) {
  74.    
  75.         cout << p[i] << endl;
  76.     }
  77. }
  78.  
  79. */
  80.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement