从键盘接收两个实数,然后按保留两位小数的格式输出这两个数的商

来源:学生作业帮助网 编辑:作业帮 时间:2024/07/14 03:10:40
从键盘接收两个实数,然后按保留两位小数的格式输出这两个数的商
xTkPW.ҴmPt8ܤ76$霈l6 6f3I_xԬ2y8|sC#3Nsi {}~I j:φng~G-u}[ϗ7 3Cw6L^\Q.X%ʴJH@21+5l#,Whiӥ.HsXS!cN|X88&&C= | o>-g3ӽKY8x-&h7}zⶻhe`/O Π:x~*Xwǁ[Mk V ըĮ*(k4)uSb&Dn1㻂?wu)F

从键盘接收两个实数,然后按保留两位小数的格式输出这两个数的商
从键盘接收两个实数,然后按保留两位小数的格式输出这两个数的商

从键盘接收两个实数,然后按保留两位小数的格式输出这两个数的商
#include
int main()
{
float a,b;
scanf("%f,%f",&a,&b);
printf("a/b=%.2f",a/b);
getch();
return 0;
}
这个程序是在Win-TC中运行的,并且输入的两个数要用,隔开

两个实数是数字0-9的情况
Option Explicit
Dim a As Integer
Dim b As Integer
Private Sub Form_KeyPress(KeyAscii As Integer)
If KeyAscii >= Asc("0") And KeyAscii <= Asc("9") Then
...

全部展开

两个实数是数字0-9的情况
Option Explicit
Dim a As Integer
Dim b As Integer
Private Sub Form_KeyPress(KeyAscii As Integer)
If KeyAscii >= Asc("0") And KeyAscii <= Asc("9") Then
If a = -1 Then
a = Val(Chr(KeyAscii))
ElseIf b = -1 Then
b = Val(Chr(KeyAscii))
MsgBox Format(a / b, "0.00")
a = -1
b = -1
End If
End If
End Sub
Private Sub Form_Load()
Me.KeyPreview = True
a = -1
b = -1
End Sub

收起