Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
这个布尔函数如何返回 a+b>b+a?a+b>b+a 有什么不同吗?如果您能解释此布尔函数中使用的概念,我们将不胜感激。
bool cmp(string a, string b){ return a+b>b+a; }
'cmp' 用于对向量中的元素进行排序
sort(temp.begin(), temp.end(), cmp)
完全一样
bool cmp(string a, string b){ if(a+b>b+a) return true; else return false; }
您不会返回字符串,而是返回只能是布尔值的表达式的结果。