c# 的习题
来源:百度知道 编辑:UC知道 时间:2024/05/12 18:59:55
using System;
using System.Collections;
using System.IO;
class StreamTest
{
public static void Main()
{
string text = Console.ReadLine();
ArrayList dArray = new ArrayList();
foreach (char c in text)
{
if (c > '0' && c < '9')
{
dArray.Add(c);
}
}
dArray.Sort();
FileStream fs = new FileStream("killme.txt", FileMode.Create);
StreamWriter sw = new StreamWriter(fs);
foreach (char c in dArray)
sw.Write(c);
sw.Close();
fs.Close();
}
}
给你思路吧
--首先吧输入的字符传 s 放到一个char数组 简单代码--char[] arry =s.ToCharArray();
然后就循环遍历这个char数组 取出数字 把数字在进行排列
最后写入记事本
--写入--代码
FileStream fs=new FileStream("D:\\新建文件夹\\新建 文本文档.txt",FileMode.A