

Hãy luôn nhớ cảm ơn và vote 5*
nếu câu trả lời hữu ích nhé!
#include <iostream>
using namespace std;
bool kts(char i){
int u = i-'0';
if (0<=u and u<=9){
return false;
}
else{
return true;
}
}
bool ktpa(char i){
if (i!='a' and i!='e' and i!='i' and i!='o' and i!='u' and kts(i)==true){
return true;
}
else{
return false;
}
}
int main(){
freopen("BAI1.INP","r",stdin);
freopen("BAI1.OUT","w",stdout);
long n;
cin >> n;
string s;
cin >> s;
long d=0;
for (char i:s){
if (ktpa(i)==true){
d++;
}
}
cout << d;
}
$\color{green}{\text{Cần code Python thì nói để mình thêm}}$
$\color{red}{\text{#Daoanhviet96}}$
Hãy giúp mọi người biết câu trả lời này thế nào?
uses crt;
var s : char; i, N, d : integer;
f1, f2 : text;
begin
clrscr;
assign(f1, 'BAITAP1.INP'); reset(f1);
assign(f2, 'BAITAP1,OUT'); rewrite(f2);
readln(f1, N);
i := 1; d := 0;
while (not eof(f1)) and (i <= N) do
begin
read(f1, s);
if not (s in ['e', 'u', 'o', 'a', 'i']) then
d := d + 1;
i := i + 1;
end;
write(f2, d);
close(f1); close(f2);
readln
end.
Hãy giúp mọi người biết câu trả lời này thế nào?
Bảng tin
2
0
0
b nói thuật toán đc kh
2901
47938
1864
- Nhập n - Nhập s - d=0 - for i -> s, nếu i không phải các nguyên âm hay số thì tăng biến đếm lên 1 - xuất biến đếm
2
0
0
thế cái hàm kts kia có td gì
2901
47938
1864
Cái hàm là để kiểm tra có phải phụ âm không
2901
47938
1864
À nhầm, kts là để kiểm tra nó có phải chữ không
0
50
0
ê char i:s là gì vậy