Advertisement
dllbridge

Untitled

Jun 26th, 2024 (edited)
752
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 3.04 KB | None | 0 0
  1.  
  2. #include <string.h>
  3. #include  <stdio.h>
  4.  
  5.  
  6. char szWord[99] = "SONY12",
  7.      sz_2  [99];
  8.  
  9. int _strlen(char *psz);
  10.  
  11. void _strcpy(char*, char*);
  12.  
  13. /////////////////////////////////
  14. int main()                     //
  15. {
  16.        
  17.     int n = _strlen(szWord);
  18.      
  19.     printf("n = %d\n", n);  
  20.    
  21.    _strcpy(sz_2, szWord);  
  22.    
  23.     printf("sz_2 = %s\n", sz_2);  
  24. }
  25.  
  26.  
  27.  
  28.  
  29. //////////////////////////////////////////////////
  30. void _strcpy(char *psz1, char *psz2)           //    Скопировался ли терминальный ноль?
  31. {
  32.    
  33.     int i = 0;
  34.    
  35.     do
  36.     {
  37.    
  38.        psz1[i] = psz2[i];
  39.    
  40.     }
  41.     while( psz2[++i] != 0);
  42.  
  43.    
  44.        
  45. }
  46.  
  47.  
  48.  
  49. ///////////////////////////////////
  50. int _strlen(char *psz)           //    
  51. {
  52.    
  53.     int i = 0;
  54.    
  55.     while( szWord[++i] != 0);
  56.  
  57.    
  58.        
  59. return i;        
  60. }
  61.  
  62.  
  63.  
  64.  
  65.  
  66.  
  67.  
  68.  
  69.  
  70.  
  71. /*
  72.  
  73. ///////////////////////////////////
  74. int _strlen(char *psz)           //    
  75. {
  76.    
  77.     int i = 0;
  78.    
  79.     for(; szWord[i] != 0; i++)
  80.     {
  81.    
  82.        // printf("%2d\n", szWord[i]);
  83.        
  84.  
  85.     }  // printf("%2d\n", szWord[i]);  
  86.    
  87.        
  88. return i;        
  89. }
  90.  
  91.  
  92. */
  93.  
  94.  
  95.  
  96.  
  97.  
  98.  
  99.  
  100.  
  101.  
  102.  
  103.  
  104.  
  105.  
  106.  
  107.  
  108.  
  109.  
  110.  
  111.  
  112.  
  113.       //  if(szWord[i] == 0) { printf("OGO!\n"); break; }
  114.  
  115.  
  116. /*
  117.  
  118. #include <stdlib.h>
  119. #include   <time.h>
  120. #include  <stdio.h>
  121.  
  122.  
  123. char szWord[99] = "SONY_Pictures";
  124.  
  125.  
  126. /////////////////////////////////
  127. int main()                     //
  128. {
  129.        
  130.     for(int i = 0; szWord[i] == 0; i++)
  131.     {
  132.    
  133.         printf("%c\n", szWord[i]);
  134.        
  135.       //  if(szWord[i] == 0) { printf("OGO!\n"); break; }
  136.     }
  137.        
  138. }
  139.  
  140.  
  141. */
  142.  
  143.  
  144.  
  145.  
  146.  
  147.  
  148.  
  149.  
  150.  
  151.  
  152.  
  153.  
  154.  
  155.  
  156.  
  157.  
  158.  
  159.  
  160.  
  161.  
  162.  
  163.  
  164.  
  165. /*
  166.  
  167. #include <stdlib.h>
  168. #include   <time.h>
  169. #include  <stdio.h>
  170.  
  171.  
  172. void monitor(int *p);
  173.  
  174. /////////////////////////////////
  175. int main()                     //
  176. {
  177.    
  178.     srand(time(0));
  179.  
  180.     int array[20],
  181.                nx,             //  min
  182.                ng;             //  max
  183.  
  184.  
  185.     for(int i = 0; i < 20; i++)
  186.     {
  187.        
  188.        array[i] = rand()%200;  
  189.     }
  190.    
  191.     monitor(array);
  192.    
  193.     ng = array[0];
  194.     nx = array[0];
  195.        
  196.     int nIndex_Max = 0,
  197.         nIndex_min = 0;
  198.    
  199.    
  200.     for(int i = 0; i < sizeof(array)/4; i++ )
  201.     {
  202.        
  203.       if(array[i] > ng)
  204.       {
  205.           ng = array[i];        
  206.           nIndex_Max = i;
  207.       }
  208.      
  209.       if(array[i] < nx)
  210.       {
  211.           nx = array[i];        
  212.           nIndex_min = i;
  213.       }      
  214.     }
  215.     printf("Max element array: %d, his index = %d\n", ng, nIndex_Max);
  216.     printf("min element array: %d, his index = %d\n", nx, nIndex_min);
  217.    
  218.    
  219. return 0;
  220. }
  221.  
  222.  
  223.  
  224.  
  225.  
  226.  
  227. /////////////////////////////////////////////////////
  228. void monitor(int *p)                               //
  229. {
  230.        
  231.        
  232.     for(int i = 0; i < 20; i++)
  233.     {
  234.        
  235.        printf("%d\n", p[i]);
  236.     }        
  237.        
  238. }
  239. */
  240. //1FF89C74B82CA48BA44CB6A6D570FD9C3513DA72FD004FD27806A83479FC9A09BB8CE85A988F
  241.  
  242.  
  243.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement