@ninja2
814 / 188 / 7
Регистрация: 26.09.2012
Сообщений: 2,018
|
04.06.2013, 03:24
|
|
А от мое элегантное решение
C++ | 1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
| #include <iostream>
using std::cout;
using std::endl;
using std::cin;
#include <string>
using std::string;
int main()
{
string s("Hellow world worobor wrodobor ga worlloyd dada");
string s1("aeiouy");
string s2;
char ch='w';
int count(0);
cout <<"Vvedite ctroky... ";
getline(cin,s);
cout <<"Vvedite cimvol... ";
cin >>ch;
int pos=s.find(ch);
while(pos!=string::npos)
{
if(s[pos-1]!=' ')
{
pos=s.find(ch,pos+1);
continue;
}
int pos1=s.find(' ',pos);
s2=s.substr(pos,pos1-pos);
if(s2.length()%2==0)
{
cout <<"s2= "<<s2<<endl;
int fined=s2.find_first_of(s1);
while(fined!=string::npos)
{
count++;
fined=s2.find_first_of(s1,fined+1);
}
}
pos=s.find(ch,pos+1);
}
cout <<"count= "<<count<<endl;
return 0;
} |
|
1
|