四则运算出题3
1、题目要求: 在之前自动出题程序的基础之上,添加新的功能: ①能判断用户的输入答案是否正确,正确与否,给出提示,若错误,显示正确答案; ② 能处理四则运算的混合算式。 2、实现思路: 出题思路不变,对原来程序生成的算式文本,进行读取每一个算式并进行计算,若输入的答案与结果相等,即计算正确。 3、思路整理(实现步骤): 出题步骤不变,每一行读取生成的算式文本,将其中的算式作为char数组保存,将char数组用栈保存,利用栈来决定计算顺序并计算出结果。 4、源代码: 1 using System; 2 using System.Collections.Generic; 3 using System.Linq; 4 using System.Text; 5 using System.IO; 6 7 namespace siz 8 { 9 class Program 10 { 11 static int top; 12 static int x1, y1; 13 static int size = 256; 14 static string [] s=new string[size]; 15 16 static double jisuan_ma(char [] str) 17 { 18 int l; 19 double right1; 20 int k=0; 21 char ww; 22