小学算术题测试 好多错 指点下!!!
using System;using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace 小学算数题
{
class Program
{
static void Main(string[] args)
{
write("你想做什么范围的呢?");
int max = Convert.ToInt32(Console.ReadLine());
while (true)
{
char ops;
int op;
Random r = new Random();
Random c= new Random();
Random a=(int) ((r.Next()/int.MaxValue*1.0)*max);
Random b = (int)((r.Next() / int.MaxValue * 1.0) * max);
Random op = (int)((c.Next() / int.MaxValue * 1.0) * 4);
chuti(a,ops,b);
int sum = input();
if (torf(a+b, sum)) Console.Write("正确");
else Console.Write("错误");
}
}
static void chuti(int a,char ops,int b,int op)
{
switch (op)
{
case 0: ops = '+'; Console.Write("a"); Console.Write("+"); Console.Write("b"); Console.Write("="); break;
case 1: ops = '-';
//if(a>=b)
Console.Write("a"); Console.Write("-"); Console.Write("b"); Console.Write("="); break;
//else write(a); write("+"); write(b); break;
case 2: ops = '*'; Console.Write("a"); Console.Write("*"); Console.Write("b"); Console.Write("="); break;
case 3: ops = '/'; Console.Write("a"); Console.Write("/"); Console.Write("b"); Console.Write("="); break;
}
}
static int input()
{
return Convert.ToInt32(Console.ReadLine());
}
static bool torf(int result,int input)
{
return result == input ? true : false;
}
}
}