从键盘接收两个实数,然后按保留两位小数的格式输出这两个数的商
来源:学生作业帮助网 编辑:作业帮 时间:2024/07/14 03:10:40
![从键盘接收两个实数,然后按保留两位小数的格式输出这两个数的商](/uploads/image/z/1734670-46-0.jpg?t=%E4%BB%8E%E9%94%AE%E7%9B%98%E6%8E%A5%E6%94%B6%E4%B8%A4%E4%B8%AA%E5%AE%9E%E6%95%B0%2C%E7%84%B6%E5%90%8E%E6%8C%89%E4%BF%9D%E7%95%99%E4%B8%A4%E4%BD%8D%E5%B0%8F%E6%95%B0%E7%9A%84%E6%A0%BC%E5%BC%8F%E8%BE%93%E5%87%BA%E8%BF%99%E4%B8%A4%E4%B8%AA%E6%95%B0%E7%9A%84%E5%95%86)
从键盘接收两个实数,然后按保留两位小数的格式输出这两个数的商
从键盘接收两个实数,然后按保留两位小数的格式输出这两个数的商
从键盘接收两个实数,然后按保留两位小数的格式输出这两个数的商
#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
收起