=","<=" 来对两个vector进行比较。vector a = { 0,1,2,3 };vector b = { 0,1,2,3 };bool is_equal = a == b;if (is_equal) { cout << "a==b" << endl;} else { cout << "a!=b" <">

c :vector比较-ag真人游戏

当vector里的元素是基本数据类型时,可以直接使用 "==", "!=", ">=","<=" 来对两个vector进行比较。

vector a = { 0,1,2,3 };
vector b = { 0,1,2,3 };
bool is_equal = a == b;
if (is_equal) {
  cout << "a==b" << endl;
} else {
  cout << "a!=b" << endl;
}

输出:a==b

vector a = { 0,1,2,3 };
vector b = { 0,1,2 };
bool is_equal = a == b;
if (is_equal) {
  cout << "a==b" << endl;
} else {
  cout << "a!=b" << endl;
}

输出:a!=b

vector a = { 0,1,2,3 };
vector b = { 0,1,2,4 };
bool int_comp = a >= b;
if (int_comp) {
  cout << "a>=b" << endl;
} else {
  cout << "a

输出:a

vector a = { 0,1,2,3 };
vector b = { 0,1,2 };
bool int_comp = a >= b;
if (int_comp) {
  cout << "a>=b" << endl;
} else {
  cout << "a

输出:a>=b

vector a = { 0,1,2,3 };
vector b = { 0,1,3 };
bool int_comp = a >= b;
if (int_comp) {
  cout << "a>=b" << endl;
} else {
  cout << "a

输出:a

网站地图