刚学C++ 这个程序找不到哪里错 求高手指点一下
#include<iostream>#include<algorithm>//头文件#include<functional>usingnamespacestd;voidm...
#include<iostream>
#include<algorithm> //头文件
#include<functional>
using namespace std;
void main(){
double a[]={1.1,4.4,3.3,2.2},b[4];
copy(a,a+4,ostream_iterator<double>(cout," "));
cout<<endl;
reverse_copy(a,a+4,ostream_iterator<double>(cout," "));
cout<<endl;
copy(a,a+4,b);
copy(b,b+4,ostream_iterator<double>(cout," "));
cout<<endl;
reverse_copy(b,b+4,ostream_iterator<double>(cout," "));
sort(a,a+4);
copy(a,a+4,ostream_iterator<double>(cout," "));
cout<<endl;
sort(a,a+4,greater<double>());
copy(a,a+4,ostream_iterator<double>(cout," "));
cout<<endl;
reverse_copy(a,a+4,b);
copy(b,b+4,ostream_iteratorr<double>(cout,"\n"));
cout<<endl;
double *x=find(a,a+4,4.4);
if( x==a+4) cout<<"没有值为4.4的数组元素";
else cout<<"有值为"<<*x<<"的数组元素";
cout<<endl;
}
报错是
x.exe - 1 error(s), 0 warning(s) 展开
#include<algorithm> //头文件
#include<functional>
using namespace std;
void main(){
double a[]={1.1,4.4,3.3,2.2},b[4];
copy(a,a+4,ostream_iterator<double>(cout," "));
cout<<endl;
reverse_copy(a,a+4,ostream_iterator<double>(cout," "));
cout<<endl;
copy(a,a+4,b);
copy(b,b+4,ostream_iterator<double>(cout," "));
cout<<endl;
reverse_copy(b,b+4,ostream_iterator<double>(cout," "));
sort(a,a+4);
copy(a,a+4,ostream_iterator<double>(cout," "));
cout<<endl;
sort(a,a+4,greater<double>());
copy(a,a+4,ostream_iterator<double>(cout," "));
cout<<endl;
reverse_copy(a,a+4,b);
copy(b,b+4,ostream_iteratorr<double>(cout,"\n"));
cout<<endl;
double *x=find(a,a+4,4.4);
if( x==a+4) cout<<"没有值为4.4的数组元素";
else cout<<"有值为"<<*x<<"的数组元素";
cout<<endl;
}
报错是
x.exe - 1 error(s), 0 warning(s) 展开
展开全部
#include<iostream>
#include<algorithm> //头文件
#include<functional>
using namespace std;
void main(){
double a[]={1.1,4.4,3.3,2.2},b[4];
copy(a,a+4,ostream_iterator<double>(cout," "));
cout<<endl;
reverse_copy(a,a+4,ostream_iterator<double>(cout," "));
cout<<endl;
copy(a,a+4,b);
copy(b,b+4,ostream_iterator<double>(cout," "));
cout<<endl;
reverse_copy(b,b+4,ostream_iterator<double>(cout," "));//不是
sort(a,a+4);
copy(a,a+4,ostream_iterator<double>(cout," "));
cout<<endl;
sort(a,a+4,greater<double>());
copy(a,a+4,ostream_iterator<double>(cout," "));
cout<<endl;
reverse_copy(a,a+4,b);
copy(b,b+4,ostream_iterator<double>(cout,"\n"));//ostream_iteratorr拼写错
cout<<endl;
double *x=find(a,a+4,4.4);
if( x==a+4) cout<<"没有值为4.4的数组元素";
else cout<<"有值为"<<*x<<"的数组元素";//分号写成了中文的
cout<<endl;
}
#include<algorithm> //头文件
#include<functional>
using namespace std;
void main(){
double a[]={1.1,4.4,3.3,2.2},b[4];
copy(a,a+4,ostream_iterator<double>(cout," "));
cout<<endl;
reverse_copy(a,a+4,ostream_iterator<double>(cout," "));
cout<<endl;
copy(a,a+4,b);
copy(b,b+4,ostream_iterator<double>(cout," "));
cout<<endl;
reverse_copy(b,b+4,ostream_iterator<double>(cout," "));//不是
sort(a,a+4);
copy(a,a+4,ostream_iterator<double>(cout," "));
cout<<endl;
sort(a,a+4,greater<double>());
copy(a,a+4,ostream_iterator<double>(cout," "));
cout<<endl;
reverse_copy(a,a+4,b);
copy(b,b+4,ostream_iterator<double>(cout,"\n"));//ostream_iteratorr拼写错
cout<<endl;
double *x=find(a,a+4,4.4);
if( x==a+4) cout<<"没有值为4.4的数组元素";
else cout<<"有值为"<<*x<<"的数组元素";//分号写成了中文的
cout<<endl;
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询