我找到了下面的代码,但我不明白它是什么意思:
res>?=m[2];
这是我找到代码的位置以及一些背景信息。
vector<int> m(3);
int s = 0;
... do stuff with m ...
res>?=m[2];
return res;
a >?= b
的等价形式是 a = max(a,b);
您可以查看C++中的最小和最大运算符
引用:
拥有返回两个参数的“最小值”或“最大值”的运算符非常方便。在GNU C++(但不在GNU C)中,
a <? b
是最小值,返回数字值a和b中较小的值;
a >? b是最大值,返回数字值a和b中较大的值。
顺便提一下:-a <? b
。 - Rahul Tripathi这显然不是标准的C++代码。我猜测这是赋值加三元运算符的简写,类似于赋值加二元运算符,如operator+=
等:
res = (res > m[2]) ? res : m[2];
您可以在此处阅读相关内容:C++语言的扩展:
a <? b
is the minimum, returning the smaller of the numeric values a and b;
a >? b
is the maximum, returning the larger of the numeric values a and b.