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
{
public Form1()
{
InitializeComponent();
}
String s = "";
Double y = 0;
Double x = 0;
int d = 0;
int n = 0;
private void button16_Click(object sender, EventArgs e)
{
if (s == "0") { s = ""; }
s += "0";
textBox1.Text = s;
}
private void button11_Click(object sender, EventArgs e)
{
if (s == "0") { s = ""; }
s += "0";
textBox1.Text = s;
}
private void button2_Click(object sender, EventArgs e)
{
if (s == "0") { s = ""; }
s += "1";
textBox1.Text = s;
}
private void button3_Click(object sender, EventArgs e)
{
if (s == "0") { s = ""; }
s += "2";
textBox1.Text = s;
}
private void button4_Click(object sender, EventArgs e)
{
if (s == "0") { s = ""; }
s += "3";
textBox1.Text = s;
}
private void button5_Click(object sender, EventArgs e)
{
if (s == "0") { s = ""; }
s += "4";
textBox1.Text = s;
}
private void button6_Click(object sender, EventArgs e)
{
if (s == "0") { s = ""; }
s += "5";
textBox1.Text = s;
}
private void button7_Click(object sender, EventArgs e)
{
if (s == "0") { s = ""; }
s += "6";
textBox1.Text = s;
}
private void button8_Click(object sender, EventArgs e)
{
if (s == "0") { s = ""; }
s += "7";
textBox1.Text = s;
}
private void button9_Click(object sender, EventArgs e)
{
if (s == "0") { s = ""; }
s += "8";
textBox1.Text = s;
}
private void button10_Click(object sender, EventArgs e)
{
if (s == "0") { s = ""; }
s += "9";
textBox1.Text = s;
}
private void button12_Click(object sender, EventArgs e)
{
if (d == 1) { y += Convert.ToDouble(textBox1.Text); }
else if
(d == 2) { y -= Convert.ToDouble(textBox1.Text); }
else if
(d == 3) { y *= Convert.ToDouble(textBox1.Text); }
else if
(d == 4) { y /= Convert.ToDouble(textBox1.Text); }
else if
(y == 0) { y = Convert.ToDouble(textBox1.Text); }
textBox1.Text = Convert.ToString(y);
d = 1;
s = "";
}
private void button13_Click(object sender, EventArgs e)
{
if (d == 1) { y += Convert.ToDouble(textBox1.Text); }
else if
(d == 2) { y -= Convert.ToDouble(textBox1.Text); }
else if
(d == 3) { y *= Convert.ToDouble(textBox1.Text); }
else if
(d == 4) { y /= Convert.ToDouble(textBox1.Text); }
else if
(y == 0) { y = Convert.ToDouble(textBox1.Text); }
textBox1.Text = Convert.ToString(y);
d = 2;
s = "";
}
private void button14_Click(object sender, EventArgs e)
{
if (d == 1) { y += Convert.ToDouble(textBox1.Text); }
else if
(d == 2) { y -= Convert.ToDouble(textBox1.Text); }
else if
(d == 3) { y *= Convert.ToDouble(textBox1.Text); }
else if
(d == 4) { y /= Convert.ToDouble(textBox1.Text); }
else if
(y == 0) { y = Convert.ToDouble(textBox1.Text); }
textBox1.Text = Convert.ToString(y);
d = 3;
s = "";
}
private void button15_Click(object sender, EventArgs e)
{
if (d == 1) { y += Convert.ToDouble(textBox1.Text); }
else if
(d == 2) { y -= Convert.ToDouble(textBox1.Text); }
else if
(d == 3) { y *= Convert.ToDouble(textBox1.Text); }
else if
(d == 4) { y /= Convert.ToDouble(textBox1.Text); }
else if
(y == 0) { y = Convert.ToDouble(textBox1.Text); }
textBox1.Text = Convert.ToString(y);
d = 4;
s = "";
}
private void button11_Click_1(object sender, EventArgs e)
{
s = "";
y = 0;
textBox1.Text = "0";
}
private void button1_Click(object sender, EventArgs e)
{
//determine=> 1=> + 2=> - 3=>* 4=>/ 0=> =
if (d == 1) { y += Convert.ToDouble(textBox1.Text); }
else if
(d == 2) { y -= Convert.ToDouble(textBox1.Text); }
else if
(d == 3) { y *= Convert.ToDouble(textBox1.Text); }
else if
(d == 4) { y /= Convert.ToDouble(textBox1.Text); }
else if
(y == 0) { y = Convert.ToDouble(textBox1.Text); }
else
y = Convert.ToDouble(textBox1.Text);
d = 0;
textBox1.Text = Convert.ToString(y);
}
}
}
2010年11月12日 星期五
2010年11月11日 星期四
期中考1
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
{
int[] arry = new int[10];
public Form1()
{
InitializeComponent();
}
private void button10_Click(object sender, EventArgs e)
{ int rdno;
int temp;
arry[0]=0;
arry[1]=1;
arry[2]=2;
arry[3]=3;
arry[4]=4;
arry[5]=5;
arry[6]=6;
arry[7]=7;
arry[8]=8;
for (int i = 0; i <=8; i++)
{
Random rd = new Random();
rdno = rd.Next(0, 8);
button10.Text = Convert.ToString(rdno);
temp = arry[rdno];
arry[rdno] = arry[arry.Length - (i + 1)];
arry[arry.Length - (i + 1)] = temp;
}
//output
button1.Text = Convert.ToString(arry[0]);
button2.Text = Convert.ToString(arry[1]);
button3.Text = Convert.ToString(arry[2]);
button4.Text = Convert.ToString(arry[3]);
button5.Text = Convert.ToString(arry[4]);
button6.Text = Convert.ToString(arry[5]);
button7.Text = Convert.ToString(arry[6]);
button8.Text = Convert.ToString(arry[7]);
button9.Text = Convert.ToString(arry[8]);
}
}
}
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
{
int[] arry = new int[10];
public Form1()
{
InitializeComponent();
}
private void button10_Click(object sender, EventArgs e)
{ int rdno;
int temp;
arry[0]=0;
arry[1]=1;
arry[2]=2;
arry[3]=3;
arry[4]=4;
arry[5]=5;
arry[6]=6;
arry[7]=7;
arry[8]=8;
for (int i = 0; i <=8; i++)
{
Random rd = new Random();
rdno = rd.Next(0, 8);
button10.Text = Convert.ToString(rdno);
temp = arry[rdno];
arry[rdno] = arry[arry.Length - (i + 1)];
arry[arry.Length - (i + 1)] = temp;
}
//output
button1.Text = Convert.ToString(arry[0]);
button2.Text = Convert.ToString(arry[1]);
button3.Text = Convert.ToString(arry[2]);
button4.Text = Convert.ToString(arry[3]);
button5.Text = Convert.ToString(arry[4]);
button6.Text = Convert.ToString(arry[5]);
button7.Text = Convert.ToString(arry[6]);
button8.Text = Convert.ToString(arry[7]);
button9.Text = Convert.ToString(arry[8]);
}
}
}
訂閱:
文章 (Atom)