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

来源:学生作业帮助网 编辑:六六作业网 时间:2024/05/12 09:29:48
从键盘接收两个实数,然后按保留两位小数的格式输出这两个数的商从键盘接收两个实数,然后按保留两位小数的格式输出这两个数的商从键盘接收两个实数,然后按保留两位小数的格式输出这两个数的商#includein

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

从键盘接收两个实数,然后按保留两位小数的格式输出这两个数的商
#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

收起