#include <iostream>
#include<string.h>
using namespace std;
void fun(char *s,int rozmiar){
int sam=0;
int sp=0;
long rozn=0;
long lf=0;
bool pierw=false;
long long rozw=0;
while(*s!='\0')
{
rozn++;
if(*s=='a'||*s=='i'||*s=='o'||*s=='e'||*s=='u'||*s=='y')
{
sam++;
sp=0;
}
else
{
sam=0;
sp++;
}
if((sp==3||sam==3) && pierw==true)
{
rozw=rozw+((rozn-3)*((rozmiar-3)-(lf-2)))+(rozn-3)+((rozmiar-3)-(lf-2))+1;
rozn=2;
}
else if(sp>3||sam>3)
{
rozw=rozw+1+(rozmiar-(lf+1));
rozn=2;
}
else if(sp==3||sam==3 && pierw==false){
rozw=rozw+((lf-2)*((rozmiar-3)-(lf-2)))+(lf-2)+((rozmiar-3)-(lf-2))+1;
rozn=2;
pierw=true;
}
s++;
lf++;
}
cout<<rozw<<endl;
}
int main(){
string str;
cin>>str;
char zdanie [str.length()];
strcpy(zdanie, str.c_str());
char *wsk=zdanie;
fun(wsk,str.length());
}
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 48 49 50 51 52 53 54 55 56 57 | #include <iostream> #include<string.h> using namespace std; void fun(char *s,int rozmiar){ int sam=0; int sp=0; long rozn=0; long lf=0; bool pierw=false; long long rozw=0; while(*s!='\0') { rozn++; if(*s=='a'||*s=='i'||*s=='o'||*s=='e'||*s=='u'||*s=='y') { sam++; sp=0; } else { sam=0; sp++; } if((sp==3||sam==3) && pierw==true) { rozw=rozw+((rozn-3)*((rozmiar-3)-(lf-2)))+(rozn-3)+((rozmiar-3)-(lf-2))+1; rozn=2; } else if(sp>3||sam>3) { rozw=rozw+1+(rozmiar-(lf+1)); rozn=2; } else if(sp==3||sam==3 && pierw==false){ rozw=rozw+((lf-2)*((rozmiar-3)-(lf-2)))+(lf-2)+((rozmiar-3)-(lf-2))+1; rozn=2; pierw=true; } s++; lf++; } cout<<rozw<<endl; } int main(){ string str; cin>>str; char zdanie [str.length()]; strcpy(zdanie, str.c_str()); char *wsk=zdanie; fun(wsk,str.length()); } |
English