Advertisement
dllbridge

Untitled

Feb 8th, 2022
1,135
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 3.91 KB | None | 0 0
  1.  
  2. //  Домашнее задание: Сделать функцию strcat(char *psz1, char *psz2);  
  3.  
  4. #include   <stdio.h>
  5.  
  6.  
  7.  
  8.  
  9. char sz1[97] =       "SONY ",
  10.      sz2[97] = " 1234567890";
  11.      
  12. void _strcpy(char *psz1, char *psz1);  
  13.  
  14.  
  15. //////////////////////////////////////////////////////////////////////////
  16. int main()                                                              //
  17. {
  18.    
  19.    _strcpy(sz1, sz2);
  20.     printf("%s \n", sz1);
  21.    
  22.  
  23. return 0;  
  24. }
  25.  
  26.  
  27.  
  28.  
  29. //////////////////////////////////////////////////////////////////////////
  30. void _strcpy(char *psz1, char *psz2)                                    //    
  31. {
  32.    
  33.     int res = 0;
  34.    
  35.     while(psz2[res] != 0)
  36.     {
  37.    
  38.         res ++;
  39.     }
  40.  
  41.     for(int i = 0; i < res; i++)
  42.     {
  43.    
  44.         psz1[i] = psz2[i];  
  45.     }
  46.  
  47.     psz1[res] = 0;
  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.  
  74. /*
  75. #include   <stdio.h>
  76.  
  77.  
  78.  
  79.  
  80. char sz1[97] = "SONY 1234567890";
  81.  
  82. int _strlen(char *psz);  
  83.  
  84.  
  85. //////////////////////////////////////////////////////////////////////////
  86. int main()                                                              //
  87. {
  88.    
  89.     int n = _strlen(sz1);
  90.     printf("%s \n", sz1);
  91.     printf("len = %d \n", n);
  92.  
  93. return 0;  
  94. }
  95.  
  96.  
  97.  
  98.  
  99. //////////////////////////////////////////////////////////////////////////
  100. int _strlen(char *psz)                                                  //    
  101. {
  102.    
  103.     int res = 0;
  104.    
  105.     while(psz[res] != 0)
  106.     {
  107.    
  108.         res ++;
  109.     }
  110.  
  111.    
  112.    
  113. return res;
  114. }
  115.  
  116. */
  117.  
  118.  
  119.  
  120.  
  121.  
  122.  
  123.  
  124.  
  125.  
  126.  
  127.  
  128.  
  129.  
  130.  
  131.  
  132.  
  133.  
  134.  
  135.  
  136.  
  137.  
  138.  
  139.  
  140.  
  141. /*
  142.  
  143. //////////////////////////////////////////////////////////////////////////
  144. int _strlen(char *psz)                                                  //    
  145. {
  146.    
  147.     int res = 0;
  148.    
  149.     while(psz[++res]);
  150.  
  151.    
  152.    
  153. return res;
  154. }
  155.  
  156. */
  157.  
  158.  
  159.  
  160.  
  161.  
  162.  
  163.  
  164.  
  165.  
  166.  
  167.  
  168.  
  169.  
  170.  
  171.  
  172.  
  173.  
  174.  
  175.  
  176.  
  177.  
  178.  
  179.  
  180.  
  181.  
  182.  
  183.  
  184.  
  185.  
  186.  
  187.  
  188.  
  189.  
  190. //#include  <string.h>
  191.  
  192. /*
  193.  
  194.  
  195. #include   <stdio.h>
  196. #include  <string.h>
  197.  
  198.    
  199. int arr[23]; //  arr хранит адрес arr[0]. arr = &arr[0]
  200.  
  201.  
  202.  
  203.  
  204.  
  205.  
  206. //////////////////////////////////////////////////////////////////////////
  207. int main()                                                              //
  208. {
  209.    
  210. char sz1[97], // = "SONY 1234567890",
  211.      sz2[19] = "Pictures";
  212.  
  213.     sz1[6] = 0;
  214.  
  215.     int n = strlen(sz1);
  216.     printf("%s \n", sz1);
  217.     printf("len = %d \n", n);
  218.    
  219.     for(int i = 0; i < 17; i++)
  220.     {
  221.    
  222.         printf("%3d = %c \n", sz1[i], sz1[i]);
  223.     }
  224.      
  225. return 0;  
  226. }
  227.  
  228.  
  229. */
  230.  
  231.  
  232.  
  233.  
  234.  
  235.  
  236.  
  237.  
  238.  
  239.  
  240.  
  241.  
  242.  
  243.  
  244.  
  245.  
  246.  
  247.  
  248.  
  249.  
  250.  
  251.  
  252.  
  253.  
  254.  
  255.  
  256.  
  257.  
  258.  
  259.  
  260.  
  261.  
  262.  
  263.  
  264.  
  265.  
  266.  
  267.  
  268.  
  269.     //strcat(sz1, sz2);
  270.     //strcpy(sz1, "Dima");
  271.  
  272.  
  273.  
  274.  
  275.  
  276.  
  277.  
  278.  
  279.  
  280.  
  281.  
  282.  
  283.  
  284.  
  285.  
  286.  
  287.  
  288.  
  289.  
  290.  
  291.  
  292.  
  293.  
  294. /*
  295.  
  296.  
  297. #include  <stdio.h>
  298.  
  299.    
  300. int arr[23]; //  arr хранит адрес arr[0]. arr = &arr[0]
  301.  
  302. char sz[19] = "SONY";
  303.  
  304.  
  305.  
  306. char c1 = 'S';
  307. char c2 = 'O';
  308. char c3 = 'N';
  309. char c4 = 'Y';
  310.  
  311. //////////////////////////////////////////////////////////////////////////
  312. int main()                                                              //
  313. {
  314.  
  315.  
  316.     printf("%s \n", sz);
  317.     printf("%s \n", "S_O_N_Y");    
  318.     printf("%c %c %c %c \n", 83, 79, 78, 'Y');
  319.     printf("%c %c %c %c \n", c1, c2, c3,  c4);  
  320.      
  321. return 0;  
  322. }
  323.  
  324.  
  325.  
  326. */
  327.  
  328.  
  329.  
  330.  
  331.  
  332.  
  333.  
  334.  
  335.  
  336.  
  337.  
  338.  
  339.  
  340.  
  341.  
  342.  
  343.  
  344.  
  345.  
  346.  
  347.  
  348.  
  349.  
  350.  
  351.  
  352.  
  353.  
  354.  
  355.  
  356.  
  357.  
  358.  
  359.  
  360.  
  361.  
  362.  
  363.  
  364.  
  365.  
  366.  
  367.  
  368.  
  369.  
  370. /*
  371.  
  372.  
  373. #include  <stdio.h>
  374.  
  375.    
  376. int a;
  377.     b = 1000,
  378.     c,
  379.     d,
  380.     f;
  381.  
  382. //////////////////////////////////////////////////////////////////////////
  383. int main()                                                              //
  384. {
  385.  
  386.        
  387.     printf("Books: ");
  388.     scanf ("%d",  &a);
  389.    
  390.     d = a % 7;  
  391.     f = a / 7;
  392.    
  393.     for(int for_a = 0; for_a < f; for_a++)
  394.     {
  395.         for(int for_b = 0, b = 1000; for_b < 7; for_b++, b-=55)
  396.         {
  397.             c += b;
  398.         }
  399.     }
  400.    
  401.     b = 1000;
  402.    
  403.     for (int for_a = 0; for_a < d; for_a++, b-=55)
  404.     {
  405.         c += b;
  406.     }
  407.     printf("price = %d\n", c);
  408.    
  409. return 10;    
  410. }
  411.  
  412.  
  413. */
  414.  
  415.  
  416.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement