fork download
  1. #include <iostream>
  2. #include <string.h>
  3. using namespace std;
  4. #define MAX 255
  5.  
  6. int myStrcmp(char s1[], char s2[]);
  7.  
  8. int main()
  9. {
  10. char s1[MAX], s2[MAX];
  11. cin.getline(s1,MAX);
  12. cin.getline(s2,MAX);
  13. int kt = myStrcmp(s1, s2);
  14. cout << kt << endl;
  15. return 0;
  16. }
  17.  
  18. int myStrlen(char s[]){
  19. int dem = 0;
  20. for (int i=0;s[i]!='\0';i++) ++dem;
  21. return dem;
  22. }
  23.  
  24.  
  25. int myStrcmp(char s1[], char s2[]){
  26. if (myStrlen(s1)>myStrlen(s2)) return 1;
  27. else if (myStrlen(s1)<myStrlen(s2)) return -1;
  28. else {
  29. for (int i=0;i<myStrlen(s1);i++)
  30. if (s1[i]>s2[i]) return 1;
  31. else if (s1[i]<s2[i]) return -1;
  32.  
  33. }
  34. return 0;
  35.  
  36. }
Success #stdin #stdout 0s 5292KB
stdin
Standard input is empty
stdout
0