Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cmath>
- #include <string.h>
- using namespace std;
- int myStrcmp(char a[], char b[])
- {
- int strlenA=strlen(a);
- int strlenB=strlen(b);
- for(int i=0;a[i]!=0&&b[i]!=0;i++)
- {
- if(a[i]>b[i]) return 1;
- if(b[i]>a[i]) return -1;
- }
- if (strlenA>strlenB) return 1;
- else if (strlenB>strlenA) return -1;
- return 0;
- }
- int main()
- {
- cout<<myStrcmp("world","world");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement