fork download
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. #define el "\n"
  4. #define ll long long
  5. #define ull unsigned long long
  6. #define se second
  7. #define fi first
  8. #define be begin()
  9. #define en end()
  10. #define Faster cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
  11.  
  12. int main()
  13. {
  14. Faster;
  15. string a, b; cin >> a >> b;
  16. int ok1 = 0, ok2 = 0;
  17. if(a[0] == '-') ok1 = 1;
  18. if(b[0] == '-') ok2 = 1;
  19. if(ok1 == 0 && ok2 == 0)
  20. {
  21. if(a.size() > b.size()) cout << 1;
  22. else if(a.size() < b.size()) cout << -1;
  23. else
  24. {
  25. for(int i = 0; i < a.size(); i++)
  26. {
  27. if(a[i] > b[i])
  28. {
  29. cout << 1;
  30. return 0;
  31. }
  32. if(a[i] < b[i])
  33. {
  34. cout << -1;
  35. return 0;
  36. }
  37. }
  38. cout << 0;
  39. }
  40. }
  41. else if(ok1 == 1 && ok2 == 1)
  42. {
  43. a[0] = 0;
  44. b[0] = 0;
  45. if(a.size() > b.size()) cout << -1;
  46. else if(a.size() < b.size()) cout << 1;
  47. else
  48. {
  49. for(int i = 0; i < a.size(); i++)
  50. {
  51. if(a[i] > b[i])
  52. {
  53. cout << -1;
  54. return 0;
  55. }
  56. if(a[i] < b[i])
  57. {
  58. cout << 1;
  59. return 0;
  60. }
  61. }
  62. cout << 0;
  63. }
  64. }
  65. else
  66. {
  67. if(ok1 == 1) cout << -1;
  68. else cout << 1;
  69. }
  70. return 0;
  71. }
  72.  
Success #stdin #stdout 0.01s 5288KB
stdin
-1 -2
stdout
1