价格好说~
Write a C# Console application called PostFixApp and add the Stack.cs file to your project. This program will do the following: a. Create a stack of size 20. b. Prompt the user to enter a postfix expression as a string. Eg. 234+56**+ c. Using a loop, evaluate each character in the string as follows: · If the character is a number, push it into the stack. · If the character is a mathematical operator, pop the top two numbers from the stack and apply mathematical operation on the numbers. Eg. in the above example, when + is detected, it will pop 3 and 4 and add them together. · Then push the result back into the stack. d. After the loop, pop the last number in the stack and display it as the final result. Enter a postfix expression : 234+56**+ Final result = 212
|
Stack Diagram : 6 4 5 5 30 3 3 7 7 7 7 210 2 2 2 2 2 2 2 2 212
2. Write a C# Console application called FilterByQueueApp and add the Queue.cs file to your project. The program will do the following: a. Create 2 queues - Q1 and Q2 of size 100 each. b. Ask the user to enter a string. c. Enqueue all the characters in the string into Q1. d. Next, the program will walk through each character in Q1 to see if the character is an alphabet. e. If the character is a comma (,), add a forward slash (/) to Q2. f. If the character is a number (0-9), add the hash symbol (#) to Q2. g. Otherwise, simply add the character to Q2. h. Finally, the program should print the size of Q2 and all the characters in Q2.
3. Write a C# Console application called FindNthNode and add the Node.cs and LinkedList.cs files to your project. The program will do the following: a. Randomly generates 10 numbers between 1 and 50, inclusive. b. For each random number generated, add it into the front of the linked list. c. Next, display all the numbers in the linked list. d. Ask the user to enter a number that is between 1 and 10, inclusive. This number represents the position of a Node in the linked list. For example, 1 refers to the first Node, 2 refers to the second Node and so on. e. Now the program will find the nth Node in the linked list and print its data. For instance, if n is 3, the program should return the data in the 3rd node of the linked list.
f. Add a new method in LinkedList.cs called InsertNode() which takes in two integers as parameters. The first parameter represents the data and the second parameter represents the node position. This method will create a node with the specified data (1st parameter) and insert it into the specified position (2nd parameter) of the Linked List. Test the method in the Main() method. 4. Write a C# Console application called MergeSortedQueueApp and add the Queue.cs file to your project. Then proceed to do the following: a. Create 3 queues (Q1, Q2 and Q3) of size 20 each. b. Initialize Q1 and Q2 with numbers in ascending order. Eg. Q1 may contain 2, 5, 8, 23 and Q2 contains 1, 4, 7, 14. c. Compare and combine the data in Q1 and Q2 into Q3 such that the numbers in Q3 are still in ascending order. d. Finally, print the size of Q3 and display all the numbers in Q3. Example output as follows:
Q1 : 2 5 8 23 Q2 : 1 4 7 14 After merging… Q3 Size = 8 Q3 : 1 2 4 5 7 8 14 23
|
e. Enhance your application such that it will still work even when Q1 and Q2 are of different sizes. For example,
Q1 : 2 5 8 23Q2 : 1 4 7 14 30 45After merging…Q3 Size = 10Q3 : 1 2 4 5 7 8 14 23 30 45 |
|