65,210
社区成员
发帖
与我相关
我的任务
分享find2应该是返回逆转之后的4的位置,对吧,那就应该是5.我还是不明白
#include < iostream>
#include < algorithm>
#include < functional>
using namespace std;
int main()
{
int a[]={1,2,3,4,5,6,7,8},b[8];
int *find1=find(a,a+8,4);
cout <<"数组a中'4'的位置是:" <<*find1 << endl;//查找4的位置
copy(a,a+8,b);//将数组a复制给数组b
reverse_copy(b,b+8,a);//把数组b,逆向复制给a,完成a的逆转
cout <<"数字a的内容:" << endl;
for(int i=0;i <8;i++)
cout << a[i] <<" ,";
cout <<endl;
//int *find2=find(a,a+8,4);
cout <<"数组a反转后,'4'的位置是:" <<*find1 << endl;//在查找4的位置
cout <<"\n数组b中的内容:" << endl;
for(i=0;i <8;i++)
cout << b[i] <<" ,";
return 0;
}
int *find2=find(a,a+8,5);