Advertisement
dllbridge

Untitled

May 19th, 2025
513
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.68 KB | None | 0 0
  1.  
  2.  
  3. /*
  4.  
  5. #include  <stdio.h>
  6. #include   <time.h>
  7. #include <stdlib.h>
  8.  
  9. void foo(int &);
  10.  
  11.  
  12. //////////////////////////////////////////////
  13. int  main()                                 //  
  14. {
  15.      
  16.      srand(time(0));
  17.      int array[20] = {0};
  18.  
  19.      foo(array[5]) ;
  20.     // printf(" %d\n", array[5]);
  21.      
  22.      
  23.      for(int i = 0; i < 20; i++)
  24.      {
  25.              
  26.          printf("%d \n", array[i]);    
  27.      }    
  28. }
  29.  
  30.  
  31.  
  32. //////////////////////////////////////////////
  33. void foo(int &r)                            //
  34. {
  35.      
  36.      int *p = &r;
  37.      
  38.      p = p - 5;
  39.      
  40.      for(int i = 0; i < 20; i++)
  41.      {
  42.          p[i] = rand() % 200 + 10 ;
  43.         // printf("%d \n", &p);
  44.      }
  45. }
  46. */
  47.  
  48.  
  49.  
  50.  
  51.  
  52.  
  53.  
  54.  
  55.  
  56.  
  57.  
  58.  
  59.  
  60.  
  61.  
  62.  
  63.  
  64.  
  65.  
  66.  
  67.  
  68.  
  69.  
  70.  
  71.  
  72.  
  73. #include   <vector>
  74. #include <iostream>
  75. using namespace std;
  76.  
  77. void monitor_vector(vector<int> &r);
  78.  
  79. ////////////////////////////////////////////////
  80. int main()
  81. {
  82.  
  83.     setlocale(LC_ALL, "rus");  
  84.    
  85.    
  86.     int nArr[20] = {5, 3, 7, 4, 3, 2, 344, 3, 2, 5, 7, 8, 956, 4, 3, 54, 11};
  87.    
  88.    
  89.     cout << "sizeof nArr = " << sizeof(nArr) << endl;
  90.    
  91.     vector<int> v(nArr, nArr + (sizeof(nArr) / sizeof(int)));
  92.    
  93.   /* for(int i = 0; i < 20; i++)
  94.     {
  95.            
  96.         v.push_back(nArr[i]);    
  97.            
  98.     }*/
  99.     //cout << "Ïðèâåò - Hello !" << endl;
  100.    
  101.     v.push_back(876);
  102.     v.push_back(  5);  
  103.     monitor_vector(v);
  104.    
  105. return 0;
  106. }
  107.  
  108.  
  109.  
  110. ///////////////////////////////////////////////////
  111. void monitor_vector(vector<int> &r)
  112. {
  113.      int n = r.size();
  114.      
  115.      for(int i = 0; i < n; i++)
  116.      {
  117.              
  118.          cout << r[i] << ", ";    
  119.      }
  120.      
  121. }
  122.  
  123.  
  124.  
  125.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement