2013年4月19日 星期五
2013年4月12日 星期五
累加計算:
<xml>
<block type="variables_set" inline="false" x="-862" y="-755">
<title name="VAR">x</title>
<value name="VALUE">
<block type="text_prompt">
<title name="TYPE">NUMBER</title>
<title name="TEXT">請輸入從1加到什麼數?_</title>
</block>
</value>
<next>
<block type="variables_set" inline="false">
<title name="VAR">y</title>
<value name="VALUE">
<block type="math_number">
<title name="NUM">0</title>
</block>
</value>
<next>
<block type="controls_for" inline="true">
<title name="VAR">i</title>
<value name="FROM">
<block type="math_number">
<title name="NUM">1</title>
</block>
</value>
<value name="TO">
<block type="variables_get">
<title name="VAR">x</title>
</block>
</value>
<statement name="DO">
<block type="variables_set" inline="false">
<title name="VAR">y</title>
<value name="VALUE">
<block type="math_arithmetic" inline="true">
<title name="OP">ADD</title>
<value name="A">
<block type="variables_get">
<title name="VAR">y</title>
</block>
</value>
<value name="B">
<block type="variables_get">
<title name="VAR">i</title>
</block>
</value>
</block>
</value>
</block>
</statement>
<next>
<block type="text_print" inline="false">
<value name="TEXT">
<block type="variables_get">
<title name="VAR">y</title>
</block>
</value>
</block>
</next>
</block>
</next>
</block>
</next>
</block>
</xml>
<xml>
<block type="variables_set" inline="false" x="-862" y="-755">
<title name="VAR">x</title>
<value name="VALUE">
<block type="text_prompt">
<title name="TYPE">NUMBER</title>
<title name="TEXT">請輸入從1加到什麼數?_</title>
</block>
</value>
<next>
<block type="variables_set" inline="false">
<title name="VAR">y</title>
<value name="VALUE">
<block type="math_number">
<title name="NUM">0</title>
</block>
</value>
<next>
<block type="controls_for" inline="true">
<title name="VAR">i</title>
<value name="FROM">
<block type="math_number">
<title name="NUM">1</title>
</block>
</value>
<value name="TO">
<block type="variables_get">
<title name="VAR">x</title>
</block>
</value>
<statement name="DO">
<block type="variables_set" inline="false">
<title name="VAR">y</title>
<value name="VALUE">
<block type="math_arithmetic" inline="true">
<title name="OP">ADD</title>
<value name="A">
<block type="variables_get">
<title name="VAR">y</title>
</block>
</value>
<value name="B">
<block type="variables_get">
<title name="VAR">i</title>
</block>
</value>
</block>
</value>
</block>
</statement>
<next>
<block type="text_print" inline="false">
<value name="TEXT">
<block type="variables_get">
<title name="VAR">y</title>
</block>
</value>
</block>
</next>
</block>
</next>
</block>
</next>
</block>
</xml>
blockly平均值:
<xml>
<block type="variables_set" inline="false" x="-1182" y="-895">
<title name="VAR">x</title>
<value name="VALUE">
<block type="text_prompt">
<title name="TYPE">NUMBER</title>
<title name="TEXT">輸入幾個數 ?</title>
</block>
</value>
<next>
<block type="variables_set" inline="false">
<title name="VAR">y</title>
<value name="VALUE">
<block type="math_number">
<title name="NUM">0</title>
</block>
</value>
<next>
<block type="controls_for" inline="true">
<title name="VAR">i</title>
<value name="FROM">
<block type="math_number">
<title name="NUM">1</title>
</block>
</value>
<value name="TO">
<block type="variables_get">
<title name="VAR">x</title>
</block>
</value>
<statement name="DO">
<block type="variables_set" inline="false">
<title name="VAR">z</title>
<value name="VALUE">
<block type="text_prompt">
<title name="TYPE">NUMBER</title>
<title name="TEXT">請輸入一正整數</title>
</block>
</value>
<next>
<block type="variables_set" inline="false">
<title name="VAR">y</title>
<value name="VALUE">
<block type="math_arithmetic" inline="true">
<title name="OP">ADD</title>
<value name="A">
<block type="variables_get">
<title name="VAR">z</title>
</block>
</value>
<value name="B">
<block type="variables_get">
<title name="VAR">y</title>
</block>
</value>
</block>
</value>
</block>
</next>
</block>
</statement>
<next>
<block type="text_print" inline="false">
<value name="TEXT">
<block type="math_arithmetic" inline="true">
<title name="OP">DIVIDE</title>
<value name="A">
<block type="variables_get">
<title name="VAR">y</title>
</block>
</value>
<value name="B">
<block type="variables_get">
<title name="VAR">x</title>
</block>
</value>
</block>
</value>
</block>
</next>
</block>
</next>
</block>
</next>
</block>
</xml>
訂閱:
文章 (Atom)