Assignment of Lecture 4 For S2A2
1. 鍵盤輸入一數,利用case語句製作下列的選單,
R. Round. ( 進行取整 )
A. Absolute Value. ( 計算絕對值 )
C. Cosine ( 計算餘弦函數,即cos )
根據輸入( S/L/C, 小寫同樣有效) , 執行相對應的處理。如圖, 當選擇 R 時,進行取整。 當選擇 A 時,計算絕對值。 當選擇 C 時,計算cos。 當輸入不正確時,需作出提示。
var
x:real;R,A,C,y:char;
begin
write('input calue of x:');
readln(x);
write('Operations: R.Round. A.Absolute Value. C.Cosine. Execute(R/A/C):');
readln(y);
case y of
'R':R:=round(x);writeln(round(x)=');
'A':A:=abs(x);writeln(abs(x)=');
'C':C:=cos(x);writeln(cos(x)=');
else writeln('Invalid Input.');
end;
end.
請高手幫改..