ResistanceJke

lab13

Dec 7th, 2019
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.08 KB | None | 0 0
  1. int mystrlen(char* arr)
  2. {
  3.     int count = 0;
  4.     while (arr[count] != 0)
  5.     {
  6.         count++;
  7.     }
  8.     return count;
  9. }
  10.  
  11. char* mystrcpy(char* arr, char* arr2)
  12. {
  13.     int count = 0;
  14.     int i = 0;
  15.     while (arr2[count] != 0)
  16.     {
  17.         arr[count] = arr2[count];
  18.         count++;
  19.     }
  20.     arr[count] = 0;
  21.     return arr;
  22. }
  23.  
  24. char* mystrcat(char* arr, char* arr2)
  25. {
  26.     int i = 0;
  27.     int cnt = 0;
  28.     int lenfirst = mystrlen(arr);
  29.     int lensecond = mystrlen(arr2);
  30.     int obshaya = lenfirst + lensecond;
  31.     while (lenfirst < obshaya)
  32.     {
  33.         arr[lenfirst] = arr2[i];
  34.         i++;
  35.         lenfirst++;
  36.     }
  37.     arr[obshaya] = 0;
  38.     return arr;
  39. }
  40.  
  41. int mystrcmp(char* arr, char* arr2)
  42. {
  43.     int i = 0;
  44.     int cnt = 0;
  45.     int x;
  46.     int a, b;
  47.     int lenfirst = mystrlen(arr);
  48.     int lensecond = mystrlen(arr2);
  49.     if (lenfirst > lensecond)
  50.         x = lenfirst;
  51.     else
  52.         x = lensecond;
  53.     while (i < x)
  54.     {
  55.         if (arr[i] != arr2[i])
  56.         {
  57.             a = arr[i];
  58.             b = arr2[i];
  59.             cnt = a - b;
  60.         }
  61.         i++;
  62.     }
  63.     return cnt;
  64. }
  65.  
  66. char* mystrchr(const char* str, int c)
  67. {
  68.     int i = 0;
  69.     while (str[i] != c) ++i;
  70.     if (c == str[i])
  71.         return (char*)str + 1;
  72.     else
  73.         return 0;
  74. }
Add Comment
Please, Sign In to add comment