• 検索結果がありません。

( ) 本問を選択

N/A
N/A
Protected

Academic year: 2021

シェア "( ) 本問を選択"

Copied!
1
0
0

読み込み中.... (全文を見る)

全文

(1)

アルゴリズム ( )

本問を選択(Select this problem){ する(Yes),しない(No) } No.

次のプログラムは数式を計算する。The following program calculates a mathematical expression.

#include<stdio.h>

int e();

int f();

char token;

int e() { int a = f();

while (token == ’+’) { token = getchar();

a += f();

}

return a;

}

int f() { int a;

if (token == ’(’) { token = getchar();

a = e();

if (token ==’)’) { token = getchar();

return a;

} else

return 0;

}

else if ((’0’ <= token) && (token <= ’9’)) { a = token - ’0’;

token = getchar();

return a;

} else {

token = getchar();

return 0;

} }

int main() {

token = getchar();

printf("%d\n", e());

return 0;

}

(1) 次の入力に対する出力を書け。Write the output of the above program for the following input:

(1-a) 1+2+(3+4)+5 (1-b) 1++2++3 (1-c) 1+a+2 (1-d) 1+(2+3a+4

(2) 掛け算 (*) も扱いたい。どう直せばよいか説明せよ。We wish to allow multiplication (*). Explain how to modify.

(3) 単項演算 + -を追加したい。どう直せばよいか。We wish to add unary operations +and -. Explain how to modify.

(解答は裏面を使用しても構わない.You can use the reverse side of this answer sheet for your answering.)

参照

関連したドキュメント

をき計測磁については 約機やぞの後の梅線道燦ω @J III 祭賞設けて、滋問の使用!窓織象件後紛えているをのもあ~.正し〈誕lÉをされていない官能筏

利用している暖房機器について今冬の使用開始月と使用終了月(見込) 、今冬の使用日 数(見込)

図表の記載にあたっては、調査票の選択肢の文言を一部省略している場合がある。省略して いない選択肢は、241 ページからの「第 3

本検討では,2.2 で示した地震応答解析モデルを用いて,基準地震動 Ss による地震応答 解析を実施し,

使用言語 日本語 選考要件. 登録届を提出するまでに個別面談を受けてください。留学中で直接面談 できない場合は Skype か

○炭素とイオン成分は、Q の Mass を用いて構成比を算出 ○金属成分は、PF の Mass