『楼 主』:
生成(批阅)简单计算题的VBS
set ws=createobject("wscript.shell")
set fso=createobject("scripting.filesystemobject")
'----------------------------------------------------------------------------
if wscript.arguments.count=0 then
do
n=replace(inputbox("请输入您要生成的算法及题目个数:" & vbcrlf & vbcrlf & "A 加法练习(+)" & vbcrlf & "B 减法练习(-)"& vbcrlf & "C 乘法练习(×)"& vbcrlf & "D 除法练习(÷)" & vbcrlf & "E 混合运算练习(+,-,(,))" & vbcrlf & vbcrlf &"生成100道加法练习请输入:(A100)","系统提示","A100")," ","")
if n="" or n=false then wscript.quit:msgbox "脚本退出!",4096
if asc(lcase(left(n,1)))<97 or asc(lcase(left(n,1)))>101 then
msgbox "1输入错误,请重新输入!",16+4096,"错误"
elseif not isnumeric(mid(n,2)) then
msgbox "2输入错误,请重新输入!",16+4096,"错误"
else
exit do
end if
loop
Select Case lcase(left(n,1))
Case "a":jiafa(mid(n,2))
Case "b":jianfa(mid(n,2))
Case "c":chengfa(mid(n,2))
Case "d":chufa(mid(n,2))
Case "e":hunhe(mid(n,2))
End Select
msgbox "文件已生成,练习完成后可以把练习题拖动到该脚本上进行批阅!",4096+48,"友情提示"
else
if lcase(right(wscript.arguments(0),3))<>"txt" then msgbox "对不起,你拖放的不是文本文件!",16+4096,"错误":wscript.quit
piyue(wscript.arguments(0))
end if
'----------------------------------------------------------------------------
sub jiafa(a) '100以内加法练习
randomize
for i=1 to a
s1=s1 & int(rnd()*50) & "+" & int(rnd()*50) & "=" & vbcrlf & vbcrlf
next
call createfile("加法练习.txt",s1)
end sub
'----------------------------------------------------------------------------
sub jianfa(a) '减法练习
randomize
for i=1 to a
x=int(rnd()*100)
y=int(rnd()*100)
if x<y then tmp=x:x=y:y=tmp
s2=s2 & x & "-" & y & "=" & vbcrlf & vbcrlf
next
call createfile("减法练习.txt",s2)
end sub
'----------------------------------------------------------------------------
sub chengfa(a) '九九表练习(个位数的乘法)
randomize
for i=1 to a
s3=s3 & int(rnd()*10) & "×" & int(rnd()*10) & "=" & vbcrlf & vbcrlf
next
call createfile("个位数的乘法.txt",s3)
end sub
'----------------------------------------------------------------------------
sub chufa(a) '除法练习(个位数的除法)
randomize
m=split("1÷1;2÷1;3÷1;4÷1;5÷1;6÷1;7÷1;8÷1;9÷1;2÷2;4÷2;6÷2;8÷2;10÷2;12÷2;14÷2;16÷2;18÷2;3÷3;6÷3;9÷3;12÷3;15÷3;18÷3;21÷3;24÷3;27÷3;4÷4;8÷4;12÷4;16÷4;20÷4;24÷4;28÷4;32÷4;36÷4;5÷5;10÷5;15÷5;20÷5;25÷5;30÷5;35÷5;40÷5;45÷5;6÷6;12÷6;18÷6;24÷6;30÷6;36÷6;42÷6;48÷6;54÷6;7÷7;14÷7;21÷7;28÷7;35÷7;42÷7;49÷7;56÷7;63÷7;8÷8;16÷8;24÷8;32÷8;40÷8;48÷8;56÷8;64÷8;72÷8;9÷9;18÷9;27÷9;36÷9;45÷9;54÷9;63÷9;72÷9;81÷9",";")
l=ubound(m)
for i=1 to a
s4=s4 & m(int(rnd()*l)) & "=" & vbcrlf & vbcrlf
next
call createfile("除法练习.txt",s4)
end sub
'----------------------------------------------------------------------------
sub hunhe(a) '混合运算
randomize
for i=1 to a
w=int(rnd()*3)
select case w
case 0 'a+b+c或a+(b+c)
x=int(rnd()*33):y=int(rnd()*33):z=int(rnd()*33)
if y mod 2=0 then
s5=s5 & x & "+" & y & "+" & z &"=" & vbcrlf & vbcrlf
else
s5=s5 & x & "+(" & y & "+" & z &")=" & vbcrlf & vbcrlf
end if
case 1 'a+b-c或a-b+c或a+(b-c)
x=int(rnd()*100)
y=int(rnd()*100)
if x<y then tmp=x:x=y:y=tmp
if x mod 2=0 then
if y mod 2=0 then
s5=s5 & int(rnd()*50) & "+" & x & "-" & y &"=" & vbcrlf & vbcrlf
else
s5=s5 & int(rnd()*50) & "+(" & x & "-" & y &")=" & vbcrlf & vbcrlf
end if
else
s5=s5 & x & "-" & y & "+" & int(rnd()*50) &"=" & vbcrlf & vbcrlf
end if
case 2 'a-b-c或a-(b-c)或a-(b+c)
x=int(rnd()*100)
y=int(rnd()*100)
if x<y then tmp=x:x=y:y=tmp
h=x-y
z=int(rnd()*100)
if z=<h then
s5=s5 & x & "-" & y & "-" & z & "=" & vbcrlf & vbcrlf
elseif z>=x+y then
if z mod 2=0 then
s5=s5 & z & "-" & x & "-" & y & "=" & vbcrlf & vbcrlf
else
s5=s5 & z & "-(" & x & "+" & y & ")=" & vbcrlf & vbcrlf
end if
else
s5=s5 & z & "-(" & x & "-" & y & ")=" & vbcrlf & vbcrlf
end if
end select
next
call createfile("混合运算.txt",s5)
end sub
'----------------------------------------------------------------------------
sub createfile(name,a)
set file=fso.createtextfile(name)
file.write a
file.close
end sub
'----------------------------------------------------------------------------
sub piyue(a)
dui=0:chuo=0
set file=fso.opentextfile(a)
do while file.atendofstream<>true
t=file.readline:t=replace(t," ",""):t=replace(t,"○",""):t=replace(t,"●",""):l=instr(t,"=")
if t<>"" and mid(t,l+1)<>"" then
tc=replace(t,"×","*"):tc=replace(tc,"÷","/")
if eval(left(tc,l-1))=cint(mid(t,l+1)) then
ts=ts & t & space(30-len(t)) & "○" & vbcrlf
dui=dui+1
else
ts=ts & t & space(30-len(t)) & "●" & vbcrlf
chuo=chuo+1
end if
else
if t<>"" then
ts=ts & t & space(30-len(t)) & "●" & vbcrlf
chuo=chuo+1
else
ts=ts & t & vbcrlf
end if
end if
loop
file.close
set file=fso.createtextfile(a)
file.write ts
file.close
cj="共:"&dui+chuo&"道题,答对"&dui&"道题,得分:"& left(dui/(dui+chuo)*100,5)
ws.run chr(34) & a & chr(34)
msgbox cj,48+4096,"成绩"
end sub
|