2013年11月15日 星期五

聖誕樹*2

#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
int x,y,z,a;
for(x=0;x<10;x++)
{
for(y=x;y<10;y++)
cout<<" ";
for(z=2*x+1;z>0;z--)
cout<<"*";
for(y=2*x;y<20;y++)
cout<<" ";
for(z=2*x+1;z>0;z--)
cout<<"*";
cout<<endl;
    }
     for(a=0;a<3;a++)
cout<<"        *****                *****"<<endl;
}

2013年11月8日 星期五

C++之水仙花數



#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
int a,b,c,d,e;
for(a=1;a<9;a++)
{
     for(b=0;b<9;b++)
     {
for(c=0;c<9;c++)
{
d=c*c*c+b*b*b+a*a*a;
e=100*a+10*b+c;
if(d==e)
cout<<e<<endl;
}
     }

}
system("pause") ;
}
水仙花數是每個位數的立方為自身的三位數,例如:153=3*3*3+5*5*5+1*1*1

2013年4月12日 星期五

1加到第n個數


xml檔:

<xml>
  <block type="variables_set" inline="false" x="-1255" y="-859">
    <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">1</title>
          </block>
        </value>
        <next>
          <block type="variables_set" inline="false">
            <title name="VAR">z</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="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">z</title>
                          </block>
                        </value>
                      </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">y</title>
                              </block>
                            </value>
                            <value name="B">
                              <block type="math_number">
                                <title name="NUM">1</title>
                              </block>
                            </value>
                          </block>
                        </value>
                      </block>
                    </next>
                  </block>
                </statement>
                <next>
                  <block type="text_print" inline="false">
                    <value name="TEXT">
                      <block type="variables_get">
                        <title name="VAR">z</title>
                      </block>
                    </value>
                  </block>
                </next>
              </block>
            </next>
          </block>
        </next>
      </block>
    </next>
  </block>
</xml>

blockly 費氏數列


<xml>
  <block type="variables_set" inline="false" x="-1491" y="-490">
    <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">1</title>
          </block>
        </value>
        <next>
          <block type="variables_set" inline="false">
            <title name="VAR">z</title>
            <value name="VALUE">
              <block type="math_number">
                <title name="NUM">1</title>
              </block>
            </value>
            <next>
              <block type="variables_set" inline="false">
                <title name="VAR">k</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="math_arithmetic" inline="true">
                        <title name="OP">MINUS</title>
                        <value name="A">
                          <block type="variables_get">
                            <title name="VAR">x</title>
                          </block>
                        </value>
                        <value name="B">
                          <block type="math_number">
                            <title name="NUM">2</title>
                          </block>
                        </value>
                      </block>
                    </value>
                    <statement name="DO">
                      <block type="variables_set" inline="false">
                        <title name="VAR">k</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>
                        <next>
                          <block type="variables_set" inline="false">
                            <title name="VAR">y</title>
                            <value name="VALUE">
                              <block type="variables_get">
                                <title name="VAR">z</title>
                              </block>
                            </value>
                            <next>
                              <block type="variables_set" inline="false">
                                <titl

blockly maze

第七關:
第八關:

第九關:
第十關: