Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <compare>
- int main(int argc, char const * argv[]) {
- int a;
- int b;
- std::cout << "value of a? ";
- std::cout.flush();
- std::cin >> a;
- std::cout << "value of b? ";
- std::cout.flush();
- std::cin >> b;
- std::cout << std::endl;
- auto cmp = a <=> b;
- if (std::is_eq(cmp)) {
- std::cout << "a [" << a << "] is equal to b [" << b << ']' << '\n';
- }
- else if (std::is_lt(cmp)) {
- std::cout << "a [" << a << "] is less than b [" << b << ']' << '\n';
- }
- else {
- std::cout << "a [" << a << "] is greater than b [" << b << ']' << '\n';
- }
- std::cout << std::endl;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement