我有如下的结构定义的数组:倒车++结构在C
struct Rect {
int l;
int b;
int h;
};
输入格式为:
10 20 30 40 50 60 12 2 3
10 2 4 44 50 887 12 3 3
我已经成功地实施程序采取在输入和存储在一个Rect结构数组中。
现在我想实现一个功能,扭转输入如下输出:
12 2 3 40 50 60 10 20 30
12 3 3 44 50 887 10 2 4
我试图实现我自己的逆向功能,并使用它,但它没有工作,下面是我的反转功能:
void reverseArray(Rect *arr, int start, int end)
{
Rect *temp;
while(start < end)
{
temp = &arr[start];
arr[start] = arr[end];
arr[end] = *temp;
start++;
end--;
}
}
我该如何达到想要的格式?谢谢。
[std :: reverse](http://www.cplusplus.com/reference/algorithm/reverse/) – 101010