2010年12月2日 星期四

12/3

3DS檔


using System;
using System.Collections.Generic;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Net;
using Microsoft.Xna.Framework.Storage;
namespace GoingBeyond1_Tutorial
{
    /// <summary>
    /// This is the main type for your game
    /// </summary>
    public class Game1 : Microsoft.Xna.Framework.Game
    {
        GraphicsDeviceManager graphics;
        SpriteBatch spriteBatch;
        public Game1()
        {
            graphics = new GraphicsDeviceManager(this);
            Content.RootDirectory = "Content";
        }
        protected override void Initialize()
        {
            base.Initialize();
        }
        // Set the 3D model to draw.
        Model myModel;
        // The aspect ratio determines how to scale 3d to 2d projection.
        float aspectRatio;
        protected override void LoadContent()
        {
            // Create a new SpriteBatch, which can be used to draw textures.
            spriteBatch = new SpriteBatch(GraphicsDevice);
            myModel = Content.Load<Model>("Models\\France");
            aspectRatio = (float)graphics.GraphicsDevice.Viewport.Width /
            (float)graphics.GraphicsDevice.Viewport.Height;
        }
        protected override void UnloadContent()
        {
        }
      
        protected override void Update(GameTime gameTime)
        {
            // Allows the game to exit
            if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed)
                this.Exit();
            modelRotation += (float)gameTime.ElapsedGameTime.TotalMilliseconds * MathHelper.ToRadians(0.1f);
            base.Update(gameTime);
        }

        // Set the position of the model in world space, and set the rotation.
        Vector3 modelPosition = Vector3.Zero;
        float modelRotation = 0.0f;
        // Set the position of the camera in world space, for our view matrix.
        Vector3 cameraPosition = new Vector3(0.0f, 50.0f, 500.0f);
        protected override void Draw(GameTime gameTime)
        {
            graphics.GraphicsDevice.Clear(Color.CornflowerBlue);
            // Copy any parent transforms.
            Matrix[] transforms = new Matrix[myModel.Bones.Count];
            myModel.CopyAbsoluteBoneTransformsTo(transforms);
            // Draw the model. A model can have multiple meshes, so loop.
            foreach (ModelMesh mesh in myModel.Meshes)
            {
                // This is where the mesh orientation is set, as well as our camera and projection.
                foreach (BasicEffect effect in mesh.Effects)
                {
                    effect.EnableDefaultLighting();
                    effect.World = transforms[mesh.ParentBone.Index] * Matrix.CreateRotationY(modelRotation)
                        * Matrix.CreateTranslation(modelPosition);
                    effect.View = Matrix.CreateLookAt(cameraPosition, Vector3.Zero, Vector3.Up);
                    effect.Projection = Matrix.CreatePerspectiveFieldOfView(MathHelper.ToRadians(45.0f),
                        aspectRatio, 1.0f, 10000.0f);
                }
                // Draw the mesh, using the effects set above.
                mesh.Draw();
            }
                base.Draw(gameTime);
        }
    }
}

2010年11月26日 星期五

11/26作業

===========================class===============
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;
using Microsoft.Xna.Framework.Net;
using Microsoft.Xna.Framework.Storage;
namespace WindowsGame2
{
    class AnimatedTexture
    {
        private Texture2D aniTex;
        private int CurrentFrame = 0;
        private int numberOfFrames = 0;
        private int msBetweenFrames = 0;
        private Rectangle rect;
        private int width = 0;
        private int height = 0;
        float timer = 0;
        public AnimatedTexture(Texture2D texture, int numFrames, int msBetweenFrames)
        {
            this.aniTex = texture;
            this.numberOfFrames = numFrames;
            this.msBetweenFrames = msBetweenFrames;
            this.width = texture.Width / numberOfFrames;
            this.height = texture.Height;
            // Init rectangle  25:         rect.X = 0;
            rect.Y = 0;
            rect.Width = width;
            rect.Height = height;
        }
        public void Update(GameTime gametime)
        {
            timer += gametime.ElapsedGameTime.Milliseconds;
            if (timer >= msBetweenFrames)
            {
                timer = 0;
                if (CurrentFrame++ == numberOfFrames - 1)
                    CurrentFrame = 0;
                rect.X = CurrentFrame * width;
                rect.Y = 0;
            }
        }
        public void Render(SpriteBatch sb, Vector2 position, Color color)
        {
            sb.Draw(aniTex, position, rect, color, 0, Vector2.Zero, 2.0f, SpriteEffects.None, 0);
        }
    }
}
=====================================game1====================



using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;
using Microsoft.Xna.Framework.Net;
using Microsoft.Xna.Framework.Storage;
namespace WindowsGame2
{
    /// <summary>
    /// This is the main type for your game
    /// </summary>
    public class Game1 : Microsoft.Xna.Framework.Game
    {
        GraphicsDeviceManager graphics;
        SpriteBatch spriteBatch;
        SpriteFont font;
        Texture2D ball; 
        Vector2 ballPosition;
        Texture2D background;
        AnimatedTexture aniTex;
        public Game1()
        {
            graphics = new GraphicsDeviceManager(this);
            Content.RootDirectory = "Content";
        }
        /// <summary>
        /// Allows the game to perform any initialization it needs to before starting to run.
        /// This is where it can query for any required services and load any non-graphic
        /// related content.  Calling base.Initialize will enumerate through any components
        /// and initialize them as well.
        /// </summary>
        protected override void Initialize()
        {
            // TODO: Add your initialization logic here
            ballPosition = new Vector2(120, 120);
            base.Initialize();
        }
        /// <summary>
        /// LoadContent will be called once per game and is the place to load
        /// all of your content.
        /// </summary>
        protected override void LoadContent()
        {
            // Create a new SpriteBatch, which can be used to draw textures.
            spriteBatch = new SpriteBatch(GraphicsDevice);
            // TODO: use this.Content to load your game content here
            font = Content.Load<SpriteFont>("spritefont1");
            ball = Content.Load<Texture2D>("ball");
            background = Content.Load<Texture2D>("B1_nrbula01");
            aniTex = new AnimatedTexture(Content.Load<Texture2D>("doing_magic"), 3, 80);
        }
        /// <summary>
        /// UnloadContent will be called once per game and is the place to unload
        /// all content.
        /// </summary>
        protected override void UnloadContent()
        {
            // TODO: Unload any non ContentManager content here
        }
        /// <summary>
        /// Allows the game to run logic such as updating the world,
        /// checking for collisions, gathering input, and playing audio.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        protected override void Update(GameTime gameTime)
        {
            // Allows the game to exit
            if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed)
                this.Exit();
            aniTex.Update(gameTime);
            // TODO: Add your update logic here
            base.Update(gameTime);
        }
        /// <summary>
        /// This is called when the game should draw itself.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        protected override void Draw(GameTime gameTime)
        {
            GraphicsDevice.Clear(Color.CornflowerBlue);
            Rectangle rect;  
            rect.X = 0;
            rect.Y = 0;
            rect.Width = graphics.GraphicsDevice.Viewport.Width;
            rect.Height = graphics.GraphicsDevice.Viewport.Height;
           
            spriteBatch.Begin();  
            spriteBatch.DrawString(font, "Hello World", new Vector2(30, 30), Color.Black);
            spriteBatch.Draw(ball, ballPosition, Color.White);
            spriteBatch.Draw(background, Vector2.Zero, Color.White);
            aniTex.Render(spriteBatch, Vector2.Zero, Color.White);
            spriteBatch.End();
            // TODO: Add your drawing code here
            base.Draw(gameTime);
        }
    }
}檔案


2010年10月29日 星期五

ai 變化

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace WindowsFormsApplication1
{
    public partial class Form1 : Form
    {System.Windows.Forms.Button[] Buttons;
        System.Windows.Forms.TextBox[] TextBoxs;
        int bno;
        int[,] a = new int[4, 4];
        public Form1()
        {
            InitializeComponent();
        }

      
        private void Form1_Load(object sender, EventArgs e)
        {
            Buttons = new System.Windows.Forms.Button[9];
            TextBoxs = new System.Windows.Forms.TextBox[9];
          
            for (int i = 0; i < 9; ++i)
            {
                Buttons[i] = new Button();
               
                Buttons[i].Click += new System.EventHandler(Buttons_Click);
                this.Controls.Add(Buttons[i]);
                if (i <= 2)
                    Buttons[i].Location = new System.Drawing.Point(10 + i * 80, 10+100);
                else if (i > 2 && i <= 5)
                    Buttons[i].Location = new System.Drawing.Point(10 + (i - 3) * 80, 40+100);
                else if (i > 5 && i <= 9)
                    Buttons[i].Location = new System.Drawing.Point(10 + (i - 6) * 80, 70+100);
            }
            for (int i = 0; i < 9; ++i)
            {
                TextBoxs[i] = new TextBox();
                this.Controls.Add(TextBoxs[i]);
                if (i <= 2)
                    TextBoxs[i].Location = new System.Drawing.Point(10 + i * 100, 10);
                else if (i > 2 && i <= 5)
                    TextBoxs[i].Location = new System.Drawing.Point(10 + (i - 3) * 100, 40);
                else if (i > 5 && i <= 9)
                    TextBoxs[i].Location = new System.Drawing.Point(10 + (i - 6) * 100, 70);
            }
            TextBoxs[0].Text = "7";
            TextBoxs[1].Text = "2";
            TextBoxs[2].Text = "4";
            TextBoxs[3].Text = "5";
            TextBoxs[4].Text = "0";
            TextBoxs[5].Text = "6";
            TextBoxs[6].Text = "8";
            TextBoxs[7].Text = "3";
            TextBoxs[8].Text = "1";
        }
        public void Buttons_Click(object sender, EventArgs e)
        {
            // System.Windows.Forms.MessageBox.Show("You have clicked button " +
            //   ((System.Windows.Forms.Button)sender).Tag.ToString());
            String tnum = sender.ToString();
            int tlen = tnum.Length;
            String no = tnum.Substring(tlen - 1);
            for (int i = 0; i < 9; i++)
            {
                if (Buttons[i].Text == no)
                    bno = i;
            }
            switch (bno)
            {
                case 0:
                    if (Buttons[1].Text == "0")
                    {
                        String temp;
                        temp = Buttons[1].Text;
                        Buttons[1].Text = Buttons[0].Text;
                        Buttons[0].Text = temp;
                    }
                    if (Buttons[3].Text == "0")
                    {
                        String temp;
                        temp = Buttons[3].Text;
                        Buttons[3].Text = Buttons[0].Text;
                        Buttons[0].Text = temp;
                    }
                    break;
                case 1:
                    if (Buttons[4].Text == "0")
                    {
                        String temp;
                        temp = Buttons[4].Text;
                        Buttons[4].Text = Buttons[1].Text;
                        Buttons[1].Text = temp;
                    }
                    if (Buttons[2].Text == "0")
                    {
                        String temp;
                        temp = Buttons[2].Text;
                        Buttons[2].Text = Buttons[1].Text;
                        Buttons[1].Text = temp;
                    }
                    if (Buttons[0].Text == "0")
                    {
                        String temp;
                        temp = Buttons[0].Text;
                        Buttons[0].Text = Buttons[1].Text;
                        Buttons[1].Text = temp;
                    }
                    break;
                case 2:
                    if (Buttons[1].Text == "0")
                    {
                        String temp;
                        temp = Buttons[1].Text;
                        Buttons[1].Text = Buttons[2].Text;
                        Buttons[2].Text = temp;
                    }
                    if (Buttons[5].Text == "0")
                    {
                        String temp;
                        temp = Buttons[5].Text;
                        Buttons[5].Text = Buttons[2].Text;
                        Buttons[2].Text = temp;
                    }
                    break;
                case 3:
                    if (Buttons[0].Text == "0")
                    {
                        String temp;
                        temp = Buttons[0].Text;
                        Buttons[0].Text = Buttons[3].Text;
                        Buttons[3].Text = temp;
                    }
                    if (Buttons[4].Text == "0")
                    {
                        String temp;
                        temp = Buttons[4].Text;
                        Buttons[4].Text = Buttons[3].Text;
                        Buttons[3].Text = temp;
                    }
                    if (Buttons[6].Text == "0")
                    {
                        String temp;
                        temp = Buttons[6].Text;
                        Buttons[6].Text = Buttons[3].Text;
                        Buttons[3].Text = temp;
                    }
                    break;
                case 4:
                    if (Buttons[1].Text == "0")
                    {
                        String temp;
                        temp = Buttons[1].Text;
                        Buttons[1].Text = Buttons[4].Text;
                        Buttons[4].Text = temp;
                    }
                    if (Buttons[3].Text == "0")
                    {
                        String temp;
                        temp = Buttons[3].Text;
                        Buttons[3].Text = Buttons[4].Text;
                        Buttons[4].Text = temp;
                    }
                    if (Buttons[5].Text == "0")
                    {
                        String temp;
                        temp = Buttons[5].Text;
                        Buttons[5].Text = Buttons[4].Text;
                        Buttons[4].Text = temp;
                    }
                    if (Buttons[7].Text == "0")
                    {
                        String temp;
                        temp = Buttons[7].Text;
                        Buttons[7].Text = Buttons[4].Text;
                        Buttons[4].Text = temp;
                    }
                    break;
                case 5:
                    if (Buttons[2].Text == "0")
                    {
                        String temp;
                        temp = Buttons[2].Text;
                        Buttons[2].Text = Buttons[5].Text;
                        Buttons[5].Text = temp;
                    }
                    if (Buttons[4].Text == "0")
                    {
                        String temp;
                        temp = Buttons[4].Text;
                        Buttons[4].Text = Buttons[5].Text;
                        Buttons[5].Text = temp;
                    }
                    if (Buttons[8].Text == "0")
                    {
                        String temp;
                        temp = Buttons[8].Text;
                        Buttons[8].Text = Buttons[5].Text;
                        Buttons[5].Text = temp;
                    }
                    break;
                case 6:
                    if (Buttons[3].Text == "0")
                    {
                        String temp;
                        temp = Buttons[3].Text;
                        Buttons[3].Text = Buttons[6].Text;
                        Buttons[6].Text = temp;
                    }
                    if (Buttons[7].Text == "0")
                    {
                        String temp;
                        temp = Buttons[7].Text;
                        Buttons[7].Text = Buttons[6].Text;
                        Buttons[6].Text = temp;
                    }
                    break;
                case 7:
                    if (Buttons[4].Text == "0")
                    {
                        String temp;
                        temp = Buttons[4].Text;
                        Buttons[4].Text = Buttons[7].Text;
                        Buttons[7].Text = temp;
                    }
                    if (Buttons[6].Text == "0")
                    {
                        String temp;
                        temp = Buttons[6].Text;
                        Buttons[6].Text = Buttons[7].Text;
                        Buttons[7].Text = temp;
                    }
                    if (Buttons[8].Text == "0")
                    {
                        String temp;
                        temp = Buttons[8].Text;
                        Buttons[8].Text = Buttons[7].Text;
                        Buttons[7].Text = temp;
                    }
                    break;
                case 8:
                    if (Buttons[5].Text == "0")
                    {
                        String temp;
                        temp = Buttons[5].Text;
                        Buttons[5].Text = Buttons[8].Text;
                        Buttons[8].Text = temp;
                    }
                    if (Buttons[7].Text == "0")
                    {
                        String temp;
                        temp = Buttons[].Text;
                        Buttons[7].Text = Buttons[8].Text;
                        Buttons[8].Text = temp;
                    }
                    break;
            }
        }

        private void button1_Click(object sender, EventArgs e)
        {
         
           a[1,1]= Convert.ToInt16(TextBoxs[0].Text);
           a[1, 2] = Convert.ToInt16(TextBoxs[1].Text);
           a[1, 3] = Convert.ToInt16(TextBoxs[2].Text);
           a[2, 1] = Convert.ToInt16(TextBoxs[3].Text);
           a[2, 2] = Convert.ToInt16(TextBoxs[4].Text);
           a[2, 3] = Convert.ToInt16(TextBoxs[5].Text);
           a[3, 1] = Convert.ToInt16(TextBoxs[6].Text);
           a[3, 2] = Convert.ToInt16(TextBoxs[7].Text);
           a[3, 3] = Convert.ToInt16(TextBoxs[8].Text);
          
           for (int i = 0; i < 9; i++)
           {
               if (i < 3)
               {
                   Buttons[i].Text = Convert.ToString(a[1, i + 1]);
               }
               else if (i >= 3 && i < 6)
               {
                   Buttons[i].Text = Convert.ToString(a[2, (i - 3) + 1]);
               }
               else
               {
                   Buttons[i].Text = Convert.ToString(a[3, (i - 3 * 2) + 1]);
               }
           }
        }
       
    }
        }
       
   

2010年10月8日 星期五

第4次作業

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace WindowsFormsApplication1
{
    public partial class Form2 : Form
    {
        public Form2()
        {
            InitializeComponent();
        }
        private void button1_Click(object sender, EventArgs e)
        {

            int a1 = 0, a2 = 0, a3 = 0, a4 = 0, a5 = 0, a6 = 0, a7 = 0, a8 = 0, a9 = 0;
            int b1 = 0, b2 = 0, b3 = 0, b4 = 0, b5 = 0, b6 = 0, b7 = 0, b8 = 0, b9 = 0;
            int c1 = 0, c2 = 0, c3 = 0, c4 = 0, c5 = 0, c6 = 0, c7 = 0, c8 = 0, c9 = 0;
            int[,] a = new int[3, 3];
            int[,] b = new int[3, 3];
            int[,] c = new int[3, 3];
            String output;
           
          
           

            a1 = int.Parse(textBox1.Text);
            a2 = int.Parse(textBox2.Text);
            a3 = int.Parse(textBox3.Text);
            a4 = int.Parse(textBox4.Text);
            a5 = int.Parse(textBox5.Text);
            a6 = int.Parse(textBox6.Text);
            a7 = int.Parse(textBox7.Text);
            a8 = int.Parse(textBox8.Text);
            a9 = int.Parse(textBox.Text);
           
            b1 = int.Parse(textBox10.Text);
            b2 = int.Parse(textBox11.Text);
            b3 = int.Parse(textBox12.Text);
            b4 = int.Parse(textBox13.Text);
            b5 = int.Parse(textBox14.Text);
            b6 = int.Parse(textBox15.Text);
            b7 = int.Parse(textBox16.Text);
            b8 = int.Parse(textBox17.Text);
            b9 = int.Parse(textBox18.Text);

            c1 = a1 * b1 + a4 * b2 + a7 * b3;
            c2 = a2 * b1 + a5 * b2 + a8 * b3;
            c3 = a3 * b1 + a6 * b2 + a9 * b3;
            c4 = a1 * b4 + a4 * b5 + a7 * b6;
            c5 = a2 * b4 + a5 * b5 + a8 * b6;
            c6 = a3 * b4 + a6 * b5 + a9 * b6;
            c7 = a1 * b7 + a4 * b8 + a7 * b9;
            c8 = a2 * b7 + a5 * b8 + a8 * b9;
            c9 = a3 * b7 + a6 * b8 + a9 * b9;
           
            output = Convert.ToString(c1);
            textBox19.Text = Convert.ToString(c1);
            output = Convert.ToString(c2);
            textBox20.Text = Convert.ToString(c2);
            output = Convert.ToString(c3);
            textBox21.Text = Convert.ToString(c3);
            output = Convert.ToString(c4);
            textBox22.Text = Convert.ToString(c4);
            output = Convert.ToString(c5);
            textBox23.Text = Convert.ToString(c5);
            output = Convert.ToString(c6);
            textBox24.Text = Convert.ToString(c6);
            output = Convert.ToString(c7);
            textBox25.Text = Convert.ToString(c7);
            output = Convert.ToString(c8);
            textBox26.Text = Convert.ToString(c8);
            output = Convert.ToString(c9);
            textBox27.Text = Convert.ToString(c9);


        }
    }
}

2010年10月1日 星期五

第3次作業

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace WindowsFormsApplication1
{
    public partial class Form1 : Form
    {
        Form2 newform;
        public Form1()
        {
            InitializeComponent();
        }
        private void button1_Click(object sender, EventArgs e)
        {

            int a1,d,an,n,sn;
            a1 = int.Parse(textBox1.Text);
            d = int.Parse(textBox3.Text);
            n = int.Parse(textBox2.Text);
            an = a1+(n-1)*d;
            sn = (a1 + an) * n / 2;
            textBox4.Text = ""+an ;
            textBox5.Text = "" + sn;

        }
        private void Form1_Load(object sender, EventArgs e)
        {
        }
        private void textBox5_TextChanged(object sender, EventArgs e)
        {
        }
       
        private void listBox1_SelectedIndexChanged(object sender, EventArgs e)
        {
        }
        private void label6_Click(object sender, EventArgs e)
        {
        }
        private void button3_Click(object sender, EventArgs e)
        {
           
        }
        private void button2_Click(object sender, System.EventArgs e)
        {
            newform = new Form2();
            newform.Show();
        }
   
   
    }
}
=================================

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace WindowsFormsApplication1
{
    public partial class Form2 : Form
    {
        public Form2()
        {
            InitializeComponent();
        }
        private void listBox1_SelectedIndexChanged(object sender, EventArgs e)
        {

        }
        private void button1_Click(object sender, EventArgs e)
        {
           
           
           
           
           
           
           
           
           
           
            listBox1.Items.Add("1*1=1 1*2=2 1*3=3 1*4=4 1*5=5 1*6=6 1*7=7 1*8=8 1*9=9");
            listBox1.Items.Add("2*1=2 2*2=4 2*3=6 2*4=8 2*5=10 2*6=12 2*7=14 2*8=16 2*9=18");
            listBox1.Items.Add("3*1=3 3*2=6 3*3=9 3*4=12 3*5=15 3*6=18 3*7=21 3*8=24 3*9=27");
            listBox1.Items.Add("4*1=4 4*2=8 4*3=12 4*4=16 4*5=20 4*6=24 4*7=28 4*8=32 4*9=36");
            listBox1.Items.Add("5*1=5 5*2=10 5*3=15 5*4=20 5*5=25 5*6=30 5*7=35 5*8=40 5*9=45");
            listBox1.Items.Add("6*1=6 6*2=12 6*3=18 6*4=24 6*5=30 6*6=36 6*7=42 6*8=48 6*9=54");
            listBox1.Items.Add("7*1=7 7*2=14 7*3=21 7*4=28 7*5=35 7*6=42 7*7=49 7*8=56 7*9=63");
            listBox1.Items.Add("8*1=8 8*2=16 8*3=24 8*4=32 8*5=40 8*6=48 8*7=56 8*8=64 8*9=72");
            listBox1.Items.Add("9*1=9 9*2=18 9*3=27 9*4=36 9*5=45 9*6=54 9*7=63 9*8=72 9*9=81");
        }
    }
}

2010年9月17日 星期五

第一次上課

#include <stdio.h>
#include <conio.h>
int main()
{
int i;
int j;

j = 0;
for (i = 1; i <= 100; i++)
j += i;
printf("從1加到100=%d\n", j);
getch();
return(0);
}