今日の1問
応用情報技術者試験
アルゴリズムとプログラミング平成21年度 春期

文字列を引数とする関数 len, first, butfirst を用いて,関数 comp を再帰的に定義した。comp("11", "101") を呼び出したとき,返されるものはどれか。 〔関数の定義〕 len(S):文字列 S の長さを返す。S が空文字列のときは 0 を返す。 first(S):文字列 S の先頭の 1 文字の ASCII コードを返す。S が空文字列のときはエラーを返す。 butfirst(S):文字列 S の先頭の 1 文字を除いた残りの文字列を返す。S が空文字列のときはエラーを返す。 comp(A, B) begin if len(A) = 0 and len(B) = 0 then return 0; if len(A) = 0 and len(B) ≠ 0 then return 1; if len(A) ≠ 0 and len(B) = 0 then return -1; if first(A) < first(B) then return 1; if first(A) > first(B) then return -1; return comp(butfirst(A), butfirst(B)); end

ア〜エから選んでみましょう👇

出典:IPA 応用情報技術者試験 平成21年度 春期 午前 問7

応用情報技術者試験の対策をもっと
本物の過去問1万問超を無料で演習