后来看到有人这样解释
不管被除数和除数,只要有负号,那么求余的结果都是负的。 然后用他们绝对值求得的余数加上除数,就是最后的结果。 比如说 -7%5 先加上负号 ,然后7%5得2,现在变成-2了 再加上除数5 得到了3 ,同理....
#include "stdio.h"int main(int argc,char *argv[]){
int a,b
double x,y
char ch1,ch2
printf("Please enter the data...\n")
scanf("%d%d%lf%lf %c%c",&a,&b,&x,&y,&ch1,&ch2)
printf("\na=%d,b=%d\nx=%f,y=%f\nch1=%c,ch2=%c\n",a,b,x,y,ch1,ch2)
return 0
}
运行样例:
Private Sub Form_Load()Me.AutoRedraw = True
'姓名、年龄、通信地址、邮政编码、电话
Dim strname As String
Dim strage As String
Dim strAdd As String
Dim strYZ As String
Dim strPhone As String
strname = InputBox("请输入姓名:")
strage = InputBox("请输入年龄:")
strAdd = InputBox("请输入通信地址:")
strYZ = InputBox("请输入邮政编码:")
strPhone = InputBox("请输入电话:")
Print "姓名:" &strname
Print "年龄:" &strage
Print "通信地址:" &strAdd
Print "邮政编码:" &strYZ
Print "电话:" &strPhone
End Sub
第二题:
Private Sub Command1_Click()
Const dayS As Long = 86400
Const HourS As Long = 3600
Const minuteS As Long = 60
Dim i As String
i = InputBox("请输入秒数")
MsgBox "转换:" &Int(Val(i) / dayS) &"天" &Int((Val(i) - (Int(Val(i) / dayS)) * dayS) / HourS) &"时" &_
Int((Val(i) - (Int(Val(i) / dayS)) * dayS - Int((Val(i) - (Int(Val(i) / dayS)) * dayS) / HourS) * HourS) / minuteS) &"分" &Val(i) Mod 60 &"秒"
End Sub
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)