void setup() {
char[]sentence = {
'p', 'r', 'o', 'g', 'r', 'a', 'm', 'm', 'i', 'n', 'g'
};
char word = 'g';
println("The counting of letter "+(word)+" in sentense are "+ countting_char(word, sentence));
}
int countting_char(char word, char[] sentense) {
int total=0;
for (int i = 0; i<sentense.length; i++) {
if (word == sentense[i]) {
total = total + 1;
}
}
return total;
}
ไม่มีความคิดเห็น:
แสดงความคิดเห็น