Advertisement
dllbridge

Untitled

Oct 4th, 2023
793
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.91 KB | None | 0 0
  1.  
  2.  
  3. #include   <stdio.h>
  4. #include    <time.h>
  5. #include  <stdlib.h>
  6. #include  <iostream>
  7.  
  8. using namespace std;
  9.  
  10.  
  11. template <class T>
  12. void foo(T &);
  13.  
  14. /////////////////////////////////////////////////////////////
  15. int main()
  16. {
  17.    
  18.     char sz[20] = "Paramount Pictures.";  
  19.  
  20.  
  21.     foo(sz[11]);
  22. }
  23.  
  24.  
  25. template <typename T>                                //<class >
  26. //////////////////////////////////////////////////////////////
  27. void foo(T &a)
  28. {
  29.  
  30.     T *pn = &a;
  31.          
  32.     for (int i = -11; i < 10; i++)
  33.     {
  34.         //printf("%d ", pn[i]);
  35.  
  36.         cout << pn[i] << " ";
  37.     }
  38. }
  39.  
  40.  
  41.  
  42.  
  43.  
  44.  
  45.  
  46. /*
  47. #include   <stdio.h>
  48. #include    <time.h>
  49. #include  <stdlib.h>
  50. #include  <iostream>
  51.  
  52. using namespace std;
  53.  
  54.  
  55. template <class T>
  56. void foo(T &);
  57.  
  58. /////////////////////////////////////////////////////////////
  59. int main()
  60. {
  61.    
  62.     int a[20];    //srand(time(0));
  63.    
  64.     for(int i = 0; i<20;i++)
  65.     {
  66.         a[i] = rand()%200;
  67.        
  68.        
  69.         printf("%d ", a[i]);
  70.     }  
  71.    
  72.     printf("\n"       );    
  73.  
  74.     foo(a[11]);
  75. }
  76.  
  77.  
  78. template <typename T>                                //<class >
  79. //////////////////////////////////////////////////////////////
  80. void foo(T &a)
  81. {
  82.  
  83.     T *pn = &a;
  84.          
  85.     for (int i = -11; i < 10; i++)
  86.     {
  87.         //printf("%d ", pn[i]);
  88.  
  89.         cout << pn[i] << " ";
  90.     }
  91.    
  92. }
  93. */
  94.  
  95.  
  96.  
  97.  
  98.  
  99.  
  100.  
  101.  
  102.  
  103.  
  104.  
  105.  
  106.  
  107.  
  108.  
  109.  
  110.  
  111.  
  112.  
  113.  
  114.  
  115.  
  116.  
  117.  
  118. /*
  119. #include   <stdio.h>
  120. #include  <locale.h>
  121. #include  <time.h>
  122. #include  <stdlib.h>
  123.  
  124.  
  125. void foo(int &);
  126. /////////////////////////////////////////////////////////////
  127. int main()
  128. {
  129.    
  130.     int a [20];
  131.    
  132.     //srand(time(0));
  133.    
  134.     for(int i = 0; i<20;i++)
  135.     {
  136.         a[i] = rand()%200;
  137.        
  138.        
  139.         printf("%d ", a[i]);
  140.        
  141.     }
  142.         printf("\n"       );
  143.  
  144.     foo(a[11]);
  145. }
  146.  
  147. //////////////////////////////////////////////////////////////
  148. void foo(int &a)
  149. {
  150.  
  151.     int *pn = &a;
  152.          
  153.     for (int i = -11; i < 0; i++)
  154.     {
  155.         printf("%d ", pn[i]);
  156.     }
  157.    
  158. }
  159.  
  160.  
  161. */
  162.  
  163.  
  164.  
  165.  
  166.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement