Advertisement
SergeyPGUTI

8.1.4

Feb 14th, 2016
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.46 KB | None | 0 0
  1. #include <iostream>
  2. #include <cmath>
  3. #include <string.h>
  4.  
  5.  
  6. using namespace std;
  7.  
  8. int myStrcmp(char a[], char b[])
  9. {
  10.     int strlenA=strlen(a);
  11.     int strlenB=strlen(b);
  12.     for(int i=0;a[i]!=0&&b[i]!=0;i++)
  13.     {
  14.         if(a[i]>b[i]) return 1;
  15.         if(b[i]>a[i]) return -1;
  16.     }
  17.     if (strlenA>strlenB) return 1;
  18.         else if (strlenB>strlenA) return -1;
  19.     return 0;
  20. }
  21.  
  22. int main()
  23. {
  24.     cout<<myStrcmp("world","world");
  25.     return 0;
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement