输入字符串,找出该字符串中abc出现的位置
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
using namespace std;
int main()
{
vector<char> vec;
vector<char>::iterator it;
cout<<"输入第一个字符串"<<endl;
char ch;
while((ch=getchar())!='#')
vec.push_back(ch);
for(it=vec.begin();it!=vec.end();it++)
cout<<*it<<endl;
cout<<"输入第二个字符串"<<endl;
//while(ch=getchar())
char *s="abc";
int i=0;
for(i=0;i<vec.size();i++)
{
if(vec.at(i)==s[0])
cout<<s[0]<<"出现在第"<<i+1<<"个位置"<<endl;
cout<<"*******************************************************************"<<endl;
if(vec.at(i)==s[1])
cout<<s[1]<<"出现在第"<<i+1<<"个位置"<<endl;
cout<<"*******************************************************************"<<endl;
if(vec.at(i)==s[2])
cout<<s[2]<<"出现在第"<<i+1<<"个位置"<<endl;
cout<<"*******************************************************************"<<endl;
}
}