In python, one can easily determine whether arr1 is identical to arr2, for example:
[1,2,3] == [1,2,3]
{1,2,3} == {3,1,2}
(1,2,3) == (1,2,3)
How do you do this in C++?
//#include <bits/stdc++.h>
using namespace std;
int main()
{
// if ({1, 2}== {1, 2})
// cout<<" {1, 2}== {1, 2}";
if ((1, 2)== (2, 2))
cout<<" (1, 2)== (1, 2) equal";
}
if ({1, 2}== {1, 2}) cout<<" {1, 2}== {1, 2}";
throws an error error: expected primary-expression before ‘{’ token
, however, if ((1, 2)== (2, 2)) cout<<" (1, 2)== (1, 2) equal";
gives unexpected result, it thinks (1, 2) and (2, 2) are the same.
Do I have to convert list to vector do the comparison in C++, like below?
#include <iostream>
#include <vector>
using namespace std;
int main()
{
if (vector<int>({1, 2})== vector<int>({1, 2}))
cout<<" vector<int>({1, 2})== vector<int>({1, 2}";
}
So what are the data type of (1,2)
and {1,2}
in C++?