fork download
  1. #include<iostream>
  2. #include<cstdio>
  3. using namespace std;
  4. int Length(string s)
  5. {
  6. int len=0;
  7. for(int i=0;s[i]!='\0';i++)
  8. {
  9. len++;
  10. }
  11. return len;
  12. }
  13. int Compare(string s1,string s2)
  14. {
  15. int lens1=Length(s1);
  16. int lens2=Length(s2);
  17. if(lens1==lens2)
  18. {
  19. for(int i=0;i<lens1;i++)
  20. {
  21. if(s1[i]==s2[i])
  22. continue;
  23. else
  24. {
  25. if(s1[i]<s2[i])
  26. {
  27. return 1;
  28. }
  29. else
  30. {
  31. return 1;
  32. }
  33. }
  34. }
  35. return 0;
  36. }
  37. else
  38. {
  39. if(lens1<lens2)
  40. {
  41. for(int i=0;i<lens1;i++)
  42. {
  43. if(s1[i]==s2[i])
  44. continue;
  45. else
  46. {
  47. if(s1[i]<s2[i])
  48. {
  49. return 1;
  50. }
  51. else
  52. {
  53. return 1;
  54. }
  55. }
  56. }
  57. return 1;
  58. }
  59. else
  60. {
  61. for(int i=0;i<lens2;i++)
  62. {
  63. if(s1[i]==s2[i])
  64. continue;
  65. else
  66. {
  67. if(s1[i]<s2[i])
  68. {
  69. return 1;
  70. }
  71. else
  72. {
  73. return 1;
  74. }
  75. }
  76. }
  77. return -1;
  78. }}}
  79. int main()
  80. {
  81. string s1,s2;
  82. cin>>s1>>s2;
  83. cout<<Compare(s1,s2)<<endl;
  84. return 0;
  85. }
Success #stdin #stdout 0.01s 5304KB
stdin
jhuma
jhu
stdout
-1