using System;
using System.Collections.Generic;
using
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using
namespace Sort
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, System.EventArgs e)
{
OpenFileDialog dlg = new OpenFileDialog();
dlg.Multiselect = true;
if (dlg.ShowDialog() == DialogResult.OK)
{
foreach (string s in dlg.FileNames)
{
this.listBox1.Items.Add(s);
}
}
}
public void Sort(char[] Read)
{
int k = Read.Length;
for (int i = 1; i < k; i++)
{
for (int j = 0; j < k - i; j++)
{
if (Read[j] > Read[j + 1])
{
char temp;
temp = Read[j];
Read[j] = Read[j + 1];
Read[j + 1] = temp;
}
}
}
foreach (int j in Read)
{
Console.Write(j + " ");
}
Console.WriteLine("\n");
}
private void listBox2_SelectedIndexChanged(object sender, EventArgs e)
{
}
private void button2_Click(object sender, EventArgs e)
{
object str = listBox1.Items;
string str2 = (string)str;
int m = str2.Length;
char[] c1 = new char[m];
char c;
c = Convert.ToChar(str2);
for (int i = 0; i < m; i++)
{
c1[i] = str2[i];
}
Sort(c1);
}
}
}
这是
“ 源 ”
不知道怎么回事 运行 出错