大家看看:
Program division;
uses crt;
var a, b , c : real;
begin
clrscr;
write('Input Num 1 :');
readln(a);
writeln('Input Num 2 :');
readln(b);
c := a/b;
writeln('The quotient of ',a,' and ',b,' is ',c,'.');
writeln('The quotient of ',a:0:0,' and ',b:0:0,' is ',a*b:0:2,'.');
readln;
end.
我想問問: a*b:0:2個0字點解? 後個2字我就識解,解小數點後的位,請盡快回答我個0字點解。
Copyright © 2024 1QUIZZ.COM - All rights reserved.
Answers & Comments
Verified answer
a*b:0:2, 冒號後第一個數字表示以多少個格來印這個結果, 而第二個冒號後的數字是小數點佔多少位, 例如
writeln(10.5:8:2); 會印出10.50, 而前面會空3格。
writeln(10.5:4:2);會印出10.50, 總格數超出4格了, 但因為小數點前的數不能省略, 所以即使印得不整齊, 都要全數印出來。
a*b:0:2, 即是最重要是小數點後取兩位, 小數點前不用理, 有多少個數就印多少。
這樣解釋應該明白吧?
WRITELN(X:num1:num2); X is a real variable, num1 is the total amount of digits to use (including sign and period) and num2 is the number of digits after the period.請盡快挑選我個答案為最佳。