如何返回字符串" x小于y"或者" x大于y"在这种情况下,而不是bool值?
#include <iostream>
using namespace std;
int main() {
int n, m;
cin >> n >> m;
auto compare = [](int x, int y) { return x < y; };
cout << ((n == m) ? "the same" : to_string(compare(n, m)));
return 0;
}
答案 0 :(得分:2)
auto compare = [](int x, int y) {
return x < y ? "x is less than y" : "x is greater than y";
};