using System;
using System.Collections.Generic;
using
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using
using System.Globalization;
using System.Threading;
namespace Sort
{
public partial class Form1 : Form
{
public static void Sort(char[] arr, int n)
{
string strlin;
strlin=Convert.ToString(arr);
for (int i = 0; i < strlin.Length; i++)
{
for (int j = i + 1; j < strlin.Length; j++)
{
if ((Convert.ToString(arr[i]), Convert.ToString(arr[i + 1])) > 0)
{
char temp = arr[i];
arr[i] = arr[i + 1];
arr[i + 1] = temp;
}
}
}
}
public Form1()
{
//int k;
InitializeComponent();
//static int k;
}
private void button1_Click(object sender, EventArgs e)
{
OpenFileDialog file = new OpenFileDialog();
file.InitialDirectory = "d:\text";
file.Filter = "txt files (*.txt)|*.txt|All files (*.*)|*.*";
foreach (string Name in file.FileNames)
{
file.FileName = Name;
}
if (file.ShowDialog() == DialogResult.OK)
{
sr = new (file.FileName);
string str = sr.ReadToEnd();
int m = str.Length;
// k = m;
char[] array = new char[m];
for (int j = 0; j < m; j++)
{
array[j] = str[j];
}
for (int i = 1; i < str.Length; i++)
{
listBox1.Items.Add(array[i]);
}
Sort(array, m);
//--------------------------------------------------------------------------------------------------------------------------------------------
using (StreamWriter sw = new StreamWriter("MyTest.txt"))
{
for (int p = 0; p < m; p++)
sw.WriteLine(array[p]);
sw.Close();
}
}
}
//---------------------------------------------------------------------------------------------------------------------------------------------
private void button2_Click(object sender, EventArgs e)
{
string FILE_NAME = "MyTest.txt";
OpenFileDialog file = new OpenFileDialog();
using (StreamReader sr = File.OpenText(FILE_NAME))
{
st = new (FILE_NAME);
string str = st.ReadToEnd();
int m = str.Length;
// k = m;
char[] array = new char[m];
for (int j = 0; j < m; j++)
{
array[j] = str[j];
}
for (int i = 1; i < str.Length; i++)
{
listBox2.Items.Add(array[i]);
}
}
}
}
}
问题已经决绝 谢谢大家支持 谢谢
using System.Collections.Generic;
using
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using
using System.Globalization;
using System.Threading;
namespace Sort
{
public partial class Form1 : Form
{
public static void Sort(char[] arr, int n)
{
string strlin;
strlin=Convert.ToString(arr);
for (int i = 0; i < strlin.Length; i++)
{
for (int j = i + 1; j < strlin.Length; j++)
{
if ((Convert.ToString(arr[i]), Convert.ToString(arr[i + 1])) > 0)
{
char temp = arr[i];
arr[i] = arr[i + 1];
arr[i + 1] = temp;
}
}
}
}
public Form1()
{
//int k;
InitializeComponent();
//static int k;
}
private void button1_Click(object sender, EventArgs e)
{
OpenFileDialog file = new OpenFileDialog();
file.InitialDirectory = "d:\text";
file.Filter = "txt files (*.txt)|*.txt|All files (*.*)|*.*";
foreach (string Name in file.FileNames)
{
file.FileName = Name;
}
if (file.ShowDialog() == DialogResult.OK)
{
sr = new (file.FileName);
string str = sr.ReadToEnd();
int m = str.Length;
// k = m;
char[] array = new char[m];
for (int j = 0; j < m; j++)
{
array[j] = str[j];
}
for (int i = 1; i < str.Length; i++)
{
listBox1.Items.Add(array[i]);
}
Sort(array, m);
//--------------------------------------------------------------------------------------------------------------------------------------------
using (StreamWriter sw = new StreamWriter("MyTest.txt"))
{
for (int p = 0; p < m; p++)
sw.WriteLine(array[p]);
sw.Close();
}
}
}
//---------------------------------------------------------------------------------------------------------------------------------------------
private void button2_Click(object sender, EventArgs e)
{
string FILE_NAME = "MyTest.txt";
OpenFileDialog file = new OpenFileDialog();
using (StreamReader sr = File.OpenText(FILE_NAME))
{
st = new (FILE_NAME);
string str = st.ReadToEnd();
int m = str.Length;
// k = m;
char[] array = new char[m];
for (int j = 0; j < m; j++)
{
array[j] = str[j];
}
for (int i = 1; i < str.Length; i++)
{
listBox2.Items.Add(array[i]);
}
}
}
}
}
问题已经决绝 谢谢大家支持 谢谢