C# OOP Design
string strInput = Console.ReadLine().Trim(); //getAllWordsByCondictionary(strInput); //ArrayList arrWord = getAllWordsByCondictionary(strInput); //Console.WriteLine(strInput); FileStream fs; StreamReader sr; ArrayList array = new ArrayList(strInput.Length); fs = new FileStream("C:\\Temp\\input.txt", FileMode.Open); sr = new StreamReader(fs); while (false == sr.EndOfStream) { string word = sr.ReadLine().Trim(); if (word.Length <= strInput.Length && word.Length>0 ) { if(true == Include(strInput,word)) { Console.WriteLine(word); } } } Console.ReadLine(); } public static bool Include(string inputWords, string word) { char[] input = word.ToCharArray(); bool flag = true; int count = 0; for (int i = 0; flag && i < input.Length; i++) { bool fg = false; char[] words = inputWords.ToCharArray(); for (int j = 0; !fg && j < words.Length; j++) { if (input.GetValue(i).Equals(words.GetValue(j))) { fg = true; inputWords.Remove(j); } } if (fg) count++; else { flag = fg; } } return flag; }
string strInput = Console.ReadLine().Trim();
//getAllWordsByCondictionary(strInput);
//ArrayList arrWord = getAllWordsByCondictionary(strInput);
//Console.WriteLine(strInput);
FileStream fs;
StreamReader sr;
ArrayList array = new ArrayList(strInput.Length);
fs = new FileStream("C:\\Temp\\input.txt", FileMode.Open);
sr = new StreamReader(fs);
while (false == sr.EndOfStream)
{
string word = sr.ReadLine().Trim();
if (word.Length <= strInput.Length && word.Length>0 )
{
if(true == Include(strInput,word))
{
Console.WriteLine(word);
}
}
}
Console.ReadLine();
}
public static bool Include(string inputWords, string word)
{
char[] input = word.ToCharArray();
bool flag = true;
int count = 0;
- 粉丝: 17
- 资源: 2
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助