Advertisement
dllbridge

Untitled

May 1st, 2025
132
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 2.68 KB | None | 0 0
  1.  
  2. #include   <stdio.h>
  3. #include      <list>
  4. using namespace std;
  5.  
  6.  
  7. void print(int *p, int n);  
  8. void print(list<int>  &r);  
  9.  
  10. /////////////////////////////////////////////////////
  11. int main()
  12. {
  13.  
  14.     list<int> L1;
  15.        
  16.     int nArr[20] = {2, 5, 3, 8, 43, 222, 4, 77};    
  17.        
  18.        
  19.     L1.push_back(123);  
  20.     L1.push_front(44);
  21.    
  22.     for(int i = 0; i < 5; i++) L1.push_back(i);
  23.            
  24.     printf("size of L1 = %d\n", L1.size());
  25.        
  26.     print(nArr, 20) ;  
  27.     print(L1);  
  28.        
  29.        
  30. }
  31.  
  32.  
  33.  
  34. /////////////////////////////////////////////////////
  35. void print(list<int> &r)                          //
  36. {
  37.    
  38.      list<int>::iterator it = r.begin();
  39.    
  40.  
  41.      
  42.      printf("\n");
  43.    
  44.      for(int i = 0; i < r.size(); i++)
  45.      {
  46.        
  47.          printf("%d, ", *it);
  48.          it++; 
  49.      }
  50. }
  51.  
  52.  
  53. /////////////////////////////////////////////////////
  54. void print(int *p, int n)                          //
  55. {
  56.    
  57.      for(int i = 0; i < n; i++)
  58.      {
  59.          printf("%d, ", p[i]);
  60.      }
  61. }
  62.  
  63.  
  64.  
  65.  
  66.  
  67.  
  68.  
  69.  
  70.  
  71.  
  72.  
  73.  
  74.  
  75.  
  76. /*
  77.  
  78. int foo (int n);
  79. int SONY(int n);
  80.  
  81. int (*fp) (int);
  82.  
  83. #include <iostream>
  84. using namespace std;
  85.  
  86.  
  87. int foo (int n);
  88. int SONY(int n);
  89.  
  90. int (*fp) (int);
  91.  
  92.  
  93. /////////////////////////////////////////////////////
  94. int main()
  95. {
  96.  
  97.        
  98.    
  99.    
  100.     cout << "adr foo  " << (int)foo    << endl;
  101.    
  102.     fp = foo;
  103.     cout << "foo    = " <<      fp(4)  << endl;
  104.    
  105.    
  106.     cout << "foo    = " <<      foo(3) << endl;
  107.     cout << "fp  = " << (int)fp    << endl;
  108.    
  109.    
  110.     fp = SONY;
  111.    
  112.     cout << "SONY    = " <<      fp(11)  << endl;
  113. }
  114.  
  115.  
  116.  
  117.  
  118. ////////////////////////////////////////////////////////
  119. int foo(int n)
  120. {
  121.    
  122.    
  123.   return n * 10;   
  124. }
  125.  
  126.  
  127.  
  128. ////////////////////////////////////////////////////////
  129. int SONY(int n)
  130. {
  131.    
  132.    
  133.   return n - 10;   
  134. }
  135.  
  136.  
  137.  
  138.  
  139. */
  140.  
  141.  
  142.  
  143.  
  144.  
  145.  
  146.  
  147.  
  148.  
  149.  
  150.  
  151.  
  152.  
  153. /*
  154.  
  155. #include <iostream>
  156. using namespace std;
  157.  
  158.  
  159. /////////////////////////////////////////////////////
  160. int summa(int n)
  161. {
  162.    
  163.    return 100 + n; 
  164. }
  165.  
  166.  
  167.  
  168. /////////////////////////////////////////////////////
  169. int summa(int n, int n2)
  170. {
  171.    
  172.    return  n + n2; 
  173. }
  174.  
  175.  
  176. /////////////////////////////////////////////////////
  177. double summa(double f, int n)
  178. {
  179.    
  180.    return  f + n;  
  181. }
  182.  
  183. /////////////////////////////////////////////////////
  184. void summa(double f, float f2)
  185. {
  186.    
  187.    cout << f + (double)f2; 
  188. }
  189.  
  190.  
  191.  
  192. /////////////////////////////////////////////////////
  193. int main()
  194. {
  195.  
  196.        
  197.    
  198.     cout << "summa = " << summa(3   )     << endl;
  199.     cout << "summa = " << summa(3, 7)     << endl;  
  200.     cout << "summa = " << summa(3.2, 7)   << endl; 
  201.    // cout << "summa = " << summa(1.2, 2.5) << endl;
  202.    
  203.     summa(1.2, 2.5);    
  204. }
  205. */
  206.  
  207.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement