using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace WindowsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button2_Click(object sender, EventArgs e)
{
Application.Exit();
}
private void button1_Click(object sender, EventArgs e)
{
try
{
int num = Convert.ToInt32(textBox1.Text.Trim());
string str = textBox1.Text.Trim();
int lend = str.Length;
switch (lend)
{
case 1:
a();
break;
case 2:
b();
break;
case 3:
c();
break;
case 4:
d();
break;
case 5:
f();
break;
}
}
catch
{
MessageBox.Show("密碼隻能是數字!","錯誤!");
textBox1.Text = "";
}
}
private void a()
{
for (int a = 0; a <= 9; a++)
{
if (a.ToString() == textBox1.Text.Trim())
{
textBox2.Text = a.ToString();
}
}
}
private void b()
{
for (int a = 0; a <= 9; a++)
{
for (int b = 0; b <= 9; b++)
{
if (a.ToString()+b.ToString() == textBox1.Text.Trim())
{
textBox2.Text = a.ToString()+b.ToString();
}
}
}
}
private void c()
{
for (int a = 0; a <= 9; a++)
{
for (int b = 0; b <= 9; b++)
{
for (int c = 0; c <= 9; c++)
{
if (a.ToString() + b.ToString() + c.ToString() == textBox1.Text.Trim())
{
textBox2.Text=((a.ToString()) + (b.ToString()) + (c.ToString()) );
}
}
}
}
}
private void d()
{
for (int a = 0; a <= 9; a++)
{
for (int b = 0; b <= 9; b++)
{
for (int c = 0; c <= 9; c++)
{
for (int d = 0; d <= 9; d++)
{
if (((a.ToString()) + (b.ToString()) + (c.ToString()) + (d.ToString())) == textBox1.Text.Trim())
{
textBox2.Text=((a.ToString()) + (b.ToString()) + (c.ToString()) + (d.ToString()));
}
}
}
}
}
}
private void f()
{
for (int a = 0; a <= 9; a++)
{
for (int b = 0; b <= 9; b++)
{
for (int c = 0; c <= 9; c++)
{
for (int d = 0; d <= 9; d++)
{
for (int e = 0; e <= 9; e++)
{
if (((a.ToString()) + (b.ToString()) + (c.ToString()) + (d.ToString())+(e.ToString())) == textBox1.Text.Trim())
{
textBox2.Text=((a.ToString()) + (b.ToString()) + (c.ToString()) + (d.ToString()) + (e.ToString()));
}
}
}
}
}
}
}
}
}