{
switch (((e.KeyValue>95)&&(e.KeyValue<106))||(e.KeyValue==110)||(e.KeyValue==188))
{
case true:
break
default:
MessageBox.Show("You shouldn't input irregular char")
textBox1.Text = textBox1.Text.Substring(0, textBox1.Text.Length - 1)
return
}
}
private string[] arrayList(string strTemp)
{
string[] a =strTemp.Split(',')
string temp
for (int i = 0i <a.Lengthi++)
{
for (int j = i + 1j <a.Lengthj++)
{
if (Convert.ToDouble(a[i]) >Convert.ToDouble(a[j]))
{
temp = a[i]
a[i] = a[j]
a[j] = temp
}
}
}
return a
}
private void btnMin_Click(object sender, EventArgs e)
{
string[] Arr = arrayList(textBox1.Text)
if (Arr.Length!=0)
{
MessageBox.Show(Arr[0].ToString())
}
}
private void btnMax_Click(object sender, EventArgs e)
{
string[] Arr = arrayList(textBox1.Text)
if (Arr.Length != 0)
{
MessageBox.Show(Arr[Arr.Length-1].ToString())
}
}
private void btnMitoMa_Click(object sender, EventArgs e)
{
string strTemp=""
string[] Arr = arrayList(textBox1.Text)
for (int i = 0i <Arr.Lengthi++)
{
strTemp = strTemp + Arr[i].ToString()+","
}
strTemp = strTemp.Substring(0, strTemp.Length - 1)
textBox1.Text = strTemp
}
private void btnMatomin_Click(object sender, EventArgs e)
{
string strTemp=""
string[] Arr = arrayList(textBox1.Text)
for (int i = Arr.Length-1i>-1i--)
{
strTemp = strTemp + Arr[i].ToString() + ","
}
strTemp = strTemp.Substring(0, strTemp.Length - 1)
textBox1.Text = strTemp
}
scanf("%d,%d,%d"迅则,&a,&b,&c)printf("%d,%d,%d",a,b,c)
%d%d中间都不用加逗亩腔棚号圆猛。
我只写一个函数:戚返\x0d\x0a>>>def littleFunc():\x0d\x0a data =[] #初始化列表\x0d\x0a for i in range(9):#一个for循环饥仔羡\x0d\x0a num = int(raw_input("input a number please: "))#控制输入转为int\x0d\x0a data.append(num)#放入列表\x0d\x0a data.sort()#排序\x0d\x0a print data#输出\x0d\x0a\x0d\x0apython的程序扩烂拍展名是.py\x0d\x0a程序执行结果:\x0d\x0a>>>littleFunc()\x0d\x0ainput a number please: 1\x0d\x0ainput a number please: 3\x0d\x0ainput a number please: 5\x0d\x0ainput a number please: 7\x0d\x0ainput a number please: 8\x0d\x0ainput a number please: 4\x0d\x0ainput a number please: 9\x0d\x0ainput a number please: 6\x0d\x0ainput a number please: 2\x0d\x0a[1, 2, 3, 4, 5, 6, 7, 8, 9]欢迎分享,转载请注明来源:内存溢出
评论列表(0条)