?? 8-0-1.cpp
字號(hào):
#include<iostream>
#include<vector>
#include<list>
#include<string>
using namespace std;
template <class R>
R chengmax(const R& left,const R& right)
{
return left>right?left:right;
}
template <class In,class X>
In chengfind(In begin,In end,const X& x)
{
if(begin==end||*begin==x)
return begin;
begin++;
return chengfind(begin,end,x);
}
template <class In,class Out>
Out chengcopy(In begin,In end,Out dest)
{
while(begin!=end)
*dest++=*begin++;
return dest;
}
template<class For, class X>
void chengreplace(For beg, For end,const X& x,const X& y)
{
while(beg!=end)
{
if(*beg==x)
*beg=y;
beg++;
}
}
template <class T>
void chengswap(T& a,T& b)
{
T c(a);
a=b;
b=c;
}
template<class Bi>
void chengreverse(Bi begin,Bi end)
{
while(begin!=end)
{
--end;
if(begin!=end)
swap(*begin++,*end);
}
}
template<class Ran,class X>
bool binary_search(Ran begin,Ran end,const X& x)
{
while(begin<end)
{
//find the midpoint of the range
Ran mid=begin+(end-begin)/2;
//see which part of the range contains x;keep looking only in that part
if(x<*mid)
end=mid;
else if (*mid<x)
begin=mid+1;
//if we got here, then *mid==x so we're done
else
return true;
}
return false;
}
int main()
{
vector<int> v;
//read ints from the standard input and append them to v
chengcopy(istream_iterator<int>(cin),istream_iterator<int>(),
back_inserter(v));
cout<<endl;
//cout<<"binary_search=="<<binary_search(v.begin(),v.end(),8)<<endl;
//write the element of v each separated from the other by two space
chengcopy(v.begin(),v.end(),ostream_iterator<int>(cout," "));
return 0;
}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -