Comienza Ya. Es Gratis
ó regístrate con tu dirección de correo electrónico
Calculator por Mind Map: Calculator

1. การแก้ให้เป็น postfix

1.1. array

1.1.1. numbers = new int[];

1.1.1.1. ใช้เก็บค่า

1.2. stack

1.2.1. Stack myStack = new Stack(); myStack.Push("Hello"); myStack.Push("World"); myStack.Push("!");

1.3. rule

1.3.1. dictionary

1.3.1.1. กำหนดน้ำหนักของค่าเครื่องหมาย

1.3.1.1.1. +,- = 1

1.3.1.1.2. *,/ = 2

1.3.1.1.3. Dictionary<string, int> dict = new Dictionary<string, int>(); dict.Add("+", 1); dict.Add("-", 1); dict.Add("*", 2); dict.Add("/", 2);

1.3.2. นำตัวเลขที่ใส่เข้ามาเก็บไว้ใน array

1.3.3. ถ้าเจอเครื่องหมาย ให้นำมาเก็บไว้ใน stack

1.3.3.1. 1.ถ้า stack ว่างก็ push ลง stack ได้เลย

1.3.3.2. 2.ถ้า stack ไม่ว่างให้เทียบตัวด้านบน A กับ ตัวใหม่ B if (A>B) ให้ push B ลง stack ได้เลย

1.3.3.3. 3.ทำข้อ1. กับ 2. สลับกันไปเรื่อย

2. การตรวจสอบ

2.1. text

2.1.1. แยกไปเก็บไว้ใน array

2.1.2. Substring

2.1.2.1. ในกรณีถ้าตัวเลขติดกัน

2.1.2.1.1. ถ้าตัวเลขตัวแรกเป็นตัวเลข ให้ตรวจสอบว่าตัวถัดไปเป็นตัวเลขไหม โดยใช้ int.parse ถามว่ามันเป็นตัวเลขไหม แล้วก็แปลงเก็บไว้ใน array ถ้าไม่ใช่ให้ไปตรวจสอบที่ cath

2.1.2.2. String s = "aaaaabbbcccccccdd"; Char charRange = 'b'; int startIndex = s.IndexOf(charRange); int endIndex = s.LastIndexOf(charRange); int length = endIndex - startIndex + 1; Console.WriteLine("{0}.Substring({1}, {2}) = {3}", s, startIndex, length,s.Substring(startIndex, length));

2.1.3. int.parse

2.1.3.1. ตรวจสอบว่าเป็นตัวเลขไหม

2.1.4. try cath

2.1.4.1. ใช้ตัวสอบกรณีที่ไม่ใช้ตัวเลข

3. วิธีการคำนวณ

3.1. แปลงโจทย์ 5+4*3+3/3 ให้เป็น Postfix

3.1.1. Array

3.1.1.1. 5

3.1.1.1.1. 4

3.1.2. Strack

3.1.2.1. +

3.1.2.1.1. *

3.2. คำนวณ

3.2.1. 5 4 3 * + 3 3 / +

3.2.1.1. Strack

3.2.1.1.1. 5