Răspuns :
#include <vector>
#include <iostream>
using namespace std;
vector <string> words(string s)
{
vector <string> a;
string x;
s+=' ';
for (int i=0; i<s.size(); i++)
{
if (s[i]!=' ') x+=s[i];
if (s[i]==' ' && x!="")
{
a.push_back(x);
x="";
}
}
return a;
}
bool existaA(string s){
for (int i=0; i<s.size(); i++)
if (s[i]=='a') return true;
return false;
}
int main(){
string s;
getline(cin,s);
vector <string> w;
w=words(s);
int c=0;
for (int i=0; i<w.size(); i++)
{
if (existaA(w[i])) c++;
}
cout << c ;
return 0;
}
si varianta pentru Pascal
var w:array [1..1000] of string;
i,c,wl:integer; s:string;
procedure words(s:string);
var i:integer; x:string;
begin
s:=s+' ';
for i:=1 to length(s) do
begin
if (s[i]<>' ') then x:=x+s[i];
if (s[i]=' ') then
begin
wl:=wl+1;
w[wl]:=x;
x:='';
end;
end;
end;
function existaA(s:string):boolean;
var i:integer; b:boolean;
begin
b:=false;
for i:=1 to length(s) do
if (s[i]='a') then b:=true;
existaA:=b;
end;
begin
readln(s);
words(s);
for i:=1 to wl do
if (existaA(w[i])) then c:=c+1;
write(c);
end.
#include <iostream>
using namespace std;
vector <string> words(string s)
{
vector <string> a;
string x;
s+=' ';
for (int i=0; i<s.size(); i++)
{
if (s[i]!=' ') x+=s[i];
if (s[i]==' ' && x!="")
{
a.push_back(x);
x="";
}
}
return a;
}
bool existaA(string s){
for (int i=0; i<s.size(); i++)
if (s[i]=='a') return true;
return false;
}
int main(){
string s;
getline(cin,s);
vector <string> w;
w=words(s);
int c=0;
for (int i=0; i<w.size(); i++)
{
if (existaA(w[i])) c++;
}
cout << c ;
return 0;
}
si varianta pentru Pascal
var w:array [1..1000] of string;
i,c,wl:integer; s:string;
procedure words(s:string);
var i:integer; x:string;
begin
s:=s+' ';
for i:=1 to length(s) do
begin
if (s[i]<>' ') then x:=x+s[i];
if (s[i]=' ') then
begin
wl:=wl+1;
w[wl]:=x;
x:='';
end;
end;
end;
function existaA(s:string):boolean;
var i:integer; b:boolean;
begin
b:=false;
for i:=1 to length(s) do
if (s[i]='a') then b:=true;
existaA:=b;
end;
begin
readln(s);
words(s);
for i:=1 to wl do
if (existaA(w[i])) then c:=c+1;
write(c);
end.