我有一个名为 Pair 的结构数组,它有很多值。如何传递这个数组并遍历它以打印出所有值?
bool reflexive(Pair* a, int sizeOfA)
struct Pair {
int x,y;
}one[5];
int main()
{
one[0].x = one[0].y = 1;
one[1].x = one[1].y = 2;
one[2].x = one[2].y = 3;
one[3].x = one[3].y = 4;
one[4].x = one[4].y = 5;
reflexive(&one, 5); // I may also need to change this line
}
bool reflexive(Pair* a, int sizeOfA){ // This is the line that i need to change
cout << a[0].x; // I need to iterate through array and print all values
}
我的问题:如何更改我的函数以使其正常工作以及如何遍历数组?