728x90
반응형
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
adjacent_find
void main()
{
int ari[]={1,9,3,6,7,5,5,8,1,4};
vector<int> vi(&ari[0],&ari[9]);
vector<int>::iterator it;
it=adjacent_find(vi.begin(),vi.end());
if (it != vi.end()) {
printf("두 요소가 인접한 값은 %d입니다.\n",*it);
}
}
adjacent_find2
bool doublespace(char a, char b)
{
return (a==' ' && b== ' ');
}
void main()
{
const char *str="기다림은 만남을 목적으로 하지 않아도 좋다.";
const char *p,*pend=&str[strlen(str)];
for (p=str;;p++) {
p=adjacent_find(p,pend,doublespace);
if (p==pend) break;
cout << p-str << "위치에 이중 공백이 있습니다." << endl;
}
}
728x90
반응형
댓글