問題
次の擬似言語プログラムを実行したとき、変数countの値はいくつか。 文字列型: s ← "hello world" 整数型: count ← 0 整数型: i ← 1 while (i ≦ 文字数(s)) if (文字取得(s, i) = "l") count ← count + 1 endif i ← i + 1 endwhile
選択肢
- 1ア 1
- 2イ 2
- 3ウ 3
- 4エ 4
解答と解説を見る
正解
3. ウ 3
解説
"hello world"には"l"が3個(h-e-l-l-o空w-o-r-l-d)含まれます。count = 3。