Editorial for cmpint


Remember to use this editorial only when stuck, and not to copy-paste code from it. Please be respectful to the problem author and editorialist.

Submitting an official solution before solving the problem yourself is a bannable offence.

Authors: wykw

Spoiler Alert


  • Bài này đề cập đến việc so sánh 2 số có độ dài lên đến 100. Vì vậy ta sẽ sử dụng string để so sánh
  • Đầu tiên chúng ta cần xóa đi những số 0 vô nghĩa ở đầu số để tiện việc so sánh
  • while (a[0] == '0') a.erase (0 , 1);
  • while (b[0] == '0') b.erase (0 , 1);
  • Cách giải của bài này như sau
  • Nếu a có độ dài lớn hơn b thì cout dấu >.
  • Nếu a có độ dài bé hơn b thì cout dấu <.
  • Nếu a có độ dài bằng b thì :
    • Nếu a > b cout dấu >.
    • Nếu a < b cout dấu <.
    • Nếu a = b cout dấu =.

AC CODE : Tại đây



Comments

There are no comments at the moment.