public bool isOperateors(string input)
{
if (input == "+" || input == "-" || input == "*" || input == "/"|| input == "(" || input == ")" || input == "#")
{
return true;
}
else return false;
}
public Queue<string> SplitExpress(string express)
{
express += "#";
Queue<string> q = new Queue<string>();
string tempNum=string.Empty;
char[] arryExpress = express.ToArray<char>();
int i = 0;
int j = 0;
while (j<express.Length)
{
if (isOperateors(arryExpress[j].ToString()))
{
if (i != j)
{
tempNum = express.Substring(i, j - i);
q.Enqueue(tempNum);
q.Enqueue(arryExpress[j].ToString());
i = j + 1;
}
else
{
q.Enqueue(arryExpress[j].ToString());
i++;
}
}
j++;
}
//q.Enqueue("#");
return q;
}
public List<string> InorderToPostorder(Queue<string> q)
{
List<string> posterOrder = new List<string>();
Stack<string> inOrder = new Stack<string>();
inOrder.Push("#");
int count = q.Count;
for (int i = 0; i < count;i++ )
{
string item = q.Dequeue();
if (isOperateors(item))
{
string m = inOrder.First();
int n = Priority.isPriority(Priority.dicOperators[inOrder.First()],
Priority.dicOperators[item]);
while (n == 1)
{
string temp = inOrder.Pop();
if (temp != "(" && temp != ")")
{
posterOrder.Add(temp);
}
n = Priority.isPriority(Priority.dicOperators[inOrder.First()],
Priority.dicOperators[item]);
}
if (n == 2)
{
inOrder.Pop();
}
else if (n != -1)
{
inOrder.Push(item);
}
else
{
return null;
}
}
else
{
posterOrder.Add(item);
}
}
return inOrder.Count == 0 ? posterOrder : null;
}
public bool IsResult(List<string> PostorderExpress, out decimal result)
{
if (PostorderExpress != null)
{
try
{
PostorderExpress.Add("#");
string[] tempArry = PostorderExpress.ToArray();
int length = tempArry.Length;
int i = 0;
while (tempArry[i] != "#")
{
if (isOperateors(tempArry[i]))
{
tempArry[i - 2] = Arithmetic(tempArry[i - 2], tempArry[i - 1], tempArry[i]);
for (int j = i; j < length; j++)
{
if (j + 1 < length)
tempArry[j - 1] = tempArry[j + 1];
}
length -= 2;
i -= 2;
}
i++;
}
result = decimal.Parse(tempArry[0]);
return true;
}
catch (Exception e)
{
result = 0;
return false;
}
}
else
{
result = 0;
return false;
}
}
//计算方法
public string Arithmetic(string x,string y,string operators)
{
decimal a = decimal.Parse(x);
decimal b = decimal.Parse(y);
decimal result = 0;
s
witch (operators)
{
case "+":
result = a + b;
break;
case "-":
result = a - b;
break;
case "*":
result = a * b;
break;
case "/":
result = a / b;
break;
}
return result.ToString();
}
psp
| 任务内容 | 计划共完成需要的时间(h) | 实际完成需要的时间(h) |
|---|---|---|
| 计划 | 12 | 14 |
| 开发 | 10 | 12 |
| 需求分析 (包括学习新技术) | 0.5 | 1 |
| · 生成设计文档 | 1 | 2 |
| · 设计复审 (和同事审核设计文档) | 1 | 2 |
| 代码规范 (为目前的开发制定合适的规范) | 1 | 1.5 |
| 具体设计 | 1 | 1 |
| 具体编码 | 2 | 4 |
| · 代码复审 | 1 | 1.5 |
| · 测试(自我测试,修改代码,提交修改) | 1 | 1.5 |
| 报告 | 2 | 3 |
| · 测试报告 | 1 | 1 |
| 计算工作量 | 1 | 1 |
| · 事后总结 ,并提出过程改进计划 | 1 | 1 |
个人总结:
在完成这个项目的时候,加深了一些我对C#语言知识的理解,使自己的编程水平得到了一点点的提高,通过这次项目我知道任何工作都离不开计划和目标的设定,只有在具体的行动框架下才能规范自己的设计思路,督促自己完成每一个步骤,博客的撰写对项目思路的整理和自我的学习提升有着很大的帮助。
原文:https://www.cnblogs.com/yxd1102/p/14645190.html