**个人Blockly案例 **
案例说明:
Blockly作为一种编译系统,本质是基于计算机系统。计算机是20世纪最先进的科学技术发明之一,对人类的生产活动和社会活动产生了极其重要的影响。计算机可以进行数值计算,又可以进行逻辑计算,能够按照程序运行,自动、高速处理海量数据。其中,科学计算器是电子计算器的一种,可进行乘方、开方、指数、对数、三角函数、统计等方面的运算,又称函数计算器。此次Blockly案例将编程来计算指定自然数区间内(初始区间为0--100)3和5的倍数之和。改变程序中控制区间上限的变量i的值,即可实现对一定自然数区间内3和5的倍数之和的计算。
Blockly截图:
运行截图:
将i值改变,即可得到一定区间内3和5的倍数之和,如指定区间为0--10000:
**运行结果截图 **
XML代码:
v<xml xmlns="http://www.w3.org/1999/xhtml">
<variables>
<variable type="" id="\#I$Y\`xZ0??r~-\[V;\*RRJ">n</variable>
<variable type="" id="{F\|5zM3tQ\#,~Wf4TvSu1">sum</variable>
<variable type="" id="WK3U\`TT:@szX+}PA\_v9\(">i</variable>
<variable type="" id="J\[7PBF\*\|Tu\#x04\#/\*I\_-">文本</variable>
</variables>
<block type="text_print" id="PBRg[7|f)u[%Zq$@)V+q" x="88" y="-262">
<value name="TEXT">
<shadow type="text" id="6,WYAWxMF.%nESb\]O$ht">
<field name="TEXT">abc</field>
</shadow>
<block type="text" id="C\(N3q\_s@dX?XG9nNen\|!">
<field name="TEXT">欢迎使用!</field>
</block>
</value>
<next>
<block type="text\_print" id="d\|5x3n=h1!1\#G?kiEUe\(">
<value name="TEXT">
<shadow type="text" id="6,WYAWxMF.%nESb\]O$ht">
<field name="TEXT">abc</field>
</shadow>
<block type="text" id="ta@pS9/C\|?wIZz0t:Z~l">
<field name="TEXT">操作将运算得到一定自然数区间内3和5的倍数之和</field>
</block>
</value>
<next>
<block type="text\_print" id="N\|jgdOMO=Ls\(}Sg3CG7d">
<value name="TEXT">
<shadow type="text" id="4\]Rz;$K\*\`1B2?\[K\)Tud{">
<field name="TEXT">abc</field>
</shadow>
<block type="text\_prompt\_ext" id="5WIQmqPhLwke6APTfGZO">
<mutation type="TEXT"></mutation>
<field name="TYPE">TEXT</field>
<value name="TEXT">
<shadow type="text" id="\]Aio-w{5B\|3O.GLDtUHT">
<field name="TEXT">abc</field>
</shadow>
<block type="text" id="v;4O\]=sjY!xc\[pk9\]}-e">
<field name="TEXT">请输入指定区间上限</field>
</block>
</value>
</block>
</value>
<next>
<block type="text\_print" id="ZBS!/Iq\`a786~gL\[nxD3">
<value name="TEXT">
<shadow type="text" id="6,WYAWxMF.%nESb\]O$ht">
<field name="TEXT">abc</field>
</shadow>
<block type="text" id="DJG\_Z\*2}4TmhHF@L-S;\[">
<field name="TEXT">继续操作将运算得到该区间内3和5的倍数之和</field>
</block>
</value>
<next>
<block type="variables\_set" id="oh,45.P\#d1v@GWTr@TI@">
<field name="VAR" id="\#I$Y\`xZ0??r~-\[V;\*RRJ" variabletype="">n</field>
<value name="VALUE">
<block type="math\_number" id="b\#q=Qdhid7XK@nQras=G">
<field name="NUM">0</field>
</block>
</value>
<next>
<block type="variables\_set" id="6YMC^.WCMQeA+Qk{7isB">
<field name="VAR" id="WK3U\`TT:@szX+}PA\_v9\(" variabletype="">i</field>
<value name="VALUE">
<block type="math\_number" id=".qymOGvVl@!=S-Q{jagi">
<field name="NUM">6</field>
</block>
</value>
<next>
<block type="variables\_set" id=";\*Fn^@3!n9L5K3EDi!x.">
<field name="VAR" id="{F\|5zM3tQ\#,~Wf4TvSu1" variabletype="">sum</field>
<value name="VALUE">
<block type="math\_number" id="JN!L3-{$P\#PNQUvF\*ZhA">
<field name="NUM">0</field>
</block>
</value>
<next>
<block type="controls\_repeat\_ext" id="K3%cID\[fH\_kmdqW\*+suj">
<value name="TIMES">
<shadow type="math\_number" id="::-NgPM$:/kE\[RtO7r;z">
<field name="NUM">10</field>
</shadow>
<block type="variables\_get" id="zAp\*{;zxt:3^TY!{hV.E">
<field name="VAR" id="WK3U\`TT:@szX+}PA\_v9\(" variabletype="">i</field>
</block>
</value>
<statement name="DO">
<block type="variables\_set" id="O14FK4~.%7?\]{pa,A=Jz">
<field name="VAR" id="\#I$Y\`xZ0??r~-\[V;\*RRJ" variabletype="">n</field>
<value name="VALUE">
<block type="math\_arithmetic" id="I{826n\#}x1?.S\*K^H$Sn">
<field name="OP">ADD</field>
<value name="A">
<shadow type="math\_number" id="E9Zr.AS\[\|njwedDJez?@">
<field name="NUM">1</field>
</shadow>
<block type="variables\_get" id="eBm?}JbP%QxO+Gq03Oy;">
<field name="VAR" id="\#I$Y\`xZ0??r~-\[V;\*RRJ" variabletype="">n</field>
</block>
</value>
<value name="B">
<shadow type="math\_number" id="\_rNR2\)zHmOTms\)IZAu$c">
<field name="NUM">1</field>
</shadow>
<block type="math\_number" id="Dgxs..rcq^--$Msq8r!\`">
<field name="NUM">1</field>
</block>
</value>
</block>
</value>
<next>
<block type="controls\_if" id="aEYo:mMG4r3X\#Hx\)\#:!P">
<value name="IF0">
<block type="logic\_operation" id="ns\|;:xt$nkpRL{@d;PV7">
<field name="OP">OR</field>
<value name="A">
<block type="logic\_compare" id="JGD$zzKRHy\`=b,.\_aN0N">
<field name="OP">EQ</field>
<value name="A">
<block type="math\_modulo" id="nkEzWoxTn\`1oIGplU-S%">
<value name="DIVIDEND">
<shadow type="math\_number" id="sh+,R-^\[uE4Z\(J!O\)8:?">
<field name="NUM">64</field>
</shadow>
<block type="variables\_get" id="hjPdJ1ZkJ-M8uWZFMqU\`">
<field name="VAR" id="\#I$Y\`xZ0??r~-\[V;\*RRJ" variabletype="">n</field>
</block>
</value>
<value name="DIVISOR">
<shadow type="math\_number" id="1}sHAfwQDqaK-qnShpUi">
<field name="NUM">3</field>
</shadow>
</value>
</block>
</value>
<value name="B">
<block type="math\_number" id="rvQ.A^7{M8:J\)u-/T1O6">
<field name="NUM">0</field>
</block>
</value>
</block>
</value>
<value name="B">
<block type="logic\_compare" id="mv;lhEqSF8hJAEdof,sh">
<field name="OP">EQ</field>
<value name="A">
<block type="math\_modulo" id="$4f\|OW!0T\#lO{^{DJbbi">
<value name="DIVIDEND">
<shadow type="math\_number" id="sh+,R-^\[uE4Z\(J!O\)8:?">
<field name="NUM">64</field>
</shadow>
<block type="variables\_get" id="}HmOYcdo-~J5Tkvcx\#AL">
<field name="VAR" id="\#I$Y\`xZ0??r~-\[V;\*RRJ" variabletype="">n</field>
</block>
</value>
<value name="DIVISOR">
<shadow type="math\_number" id="k\[0}x~:7;4rfD8K0\_rO4">
<field name="NUM">5</field>
</shadow>
</value>
</block>
</value>
<value name="B">
<block type="math\_number" id="},nVKQ!\*O/w,+UBZxbOb">
<field name="NUM">0</field>
</block>
</value>
</block>
</value>
</block>
</value>
<statement name="DO0">
<block type="variables\_set" id=";XNrfONAx^3G\|1p1\(.NU">
<field name="VAR" id="{F\|5zM3tQ\#,~Wf4TvSu1" variabletype="">sum</field>
<value name="VALUE">
<block type="math\_arithmetic" id="J.,W\#y\]?\_X;~u\(\_Xx\)N~">
<field name="OP">ADD</field>
<value name="A">
<shadow type="math\_number" id="E9Zr.AS\[\|njwedDJez?@">
<field name="NUM">1</field>
</shadow>
<block type="variables\_get" id="B\]GMr!@7TaFm=B\`%KsGn">
<field name="VAR" id="{F\|5zM3tQ\#,~Wf4TvSu1" variabletype="">sum</field>
</block>
</value>
<value name="B">
<shadow type="math\_number" id="\_rNR2\)zHmOTms\)IZAu$c">
<field name="NUM">1</field>
</shadow>
<block type="variables\_get" id="{:;v%9~L\[8Fr\)\[.W,Iy,">
<field name="VAR" id="\#I$Y\`xZ0??r~-\[V;\*RRJ" variabletype="">n</field>
</block>
</value>
</block>
</value>
</block>
</statement>
</block>
</next>
</block>
</statement>
<next>
<block type="text\_print" id=":A7BELYo/\|\_;;7OM42SK">
<value name="TEXT">
<shadow type="text" id="6,WYAWxMF.%nESb\]O$ht">
<field name="TEXT">abc</field>
</shadow>
<block type="text" id="xAUJMGOhy\|t\*}?Zn?H\]d">
<field name="TEXT">该区间内3和5的倍数之和为</field>
</block>
</value>
<next>
<block type="text\_print" id="6}i{WZf1n%!\]\*\(A/YE\[s">
<value name="TEXT">
<shadow type="text" id="@JKDe\|VGkM\|\#o.;@NS.\(">
<field name="TEXT">abc</field>
</shadow>
<block type="variables\_get" id=",RNz/1+\_S1/7Vrw.@k72">
<field name="VAR" id="{F\|5zM3tQ\#,~Wf4TvSu1" variabletype="">sum</field>
</block>
</value>
</block>
</next>
</block>
</next>
</block>
</next>
</block>
</next>
</block>
</next>
</block>
</next>
</block>
</next>
</block>
</next>
</block>
</next>
</block>
</xml>