helsinki2103

UIT 8.09

Jan 2nd, 2021
190
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.32 KB | None | 0 0
  1. int myStrcmp(char s1[], char s2[]){
  2. int len1 = 0, len2 = 0;
  3. while (s1[len1]!='\0') len1++;
  4. while (s2[len2]!='\0') len2++;
  5. if (len1<len2) return -1;
  6. if (len1>len2) return 1;
  7. for(int i=0; i<len1; i++){
  8. if (s1[i]>s2[i]) return 1;
  9. if (s1[i]<s2[i]) return -1;
  10. }
  11. return 0;
  12. }
Advertisement
Add Comment
Please, Sign In to add comment