ibcadmin 发表于 2014-12-2 10:37:08

a1005341055 发表于 2014-12-2 02:20
还是觉得有点不对   可不可以先随机出10道题   再输入答案来判断他的对错

Randoma = new Random();
string[] s = {"+","-","*","/"};
List<int> resultList = new   List<int>();
for(int j =0;j<10;j++)
{
         int n1= a.Next();// 第一个数
      int n2 = a.Next();//第二个数
      string sn = s;//运算符
      intresult = 0; //这是答案
   switch(sn)
{
   case "+":
result= n1+n2;
      break;
   
case "-":
result= n1-n2;
      break;
case "*":
result= n1*n2;
      break;
case "/":
result= n1/n2;
      break;
}
Console.WriteLine(n1.ToString() + sn + n2.ToString()+"=" );

resultList.Add(result);

}
Console.WriteLine("输入答案,每个答案用逗号分割“,” 英文逗号");
string str = Console.ReadLine();
string[] arr= str.Split(',');
for(int i = 0;i<resultList.Count;i++;)
{
   if(Convert.ToInt32(arr)==resultList)
{
   Console.WriteLine("第"+i+"题正确");
}else
{
Console.WriteLine("第"+i+"题错误");
}
}

ibcadmin 发表于 2014-12-2 10:38:28

if(Convert.ToInt32(arr)==resultList)   换成if(Convert.ToInt32(arr【i】)==resultList【i】)

a1005341055 发表于 2014-12-2 10:46:04

ibcadmin 发表于 2014-12-2 10:37
Randoma = new Random();
string[] s = {"+","-","*","/"};
List resultList = new   List();


有错误   if (Convert.ToInt32(arr) == resultList)   这个错了   说==无法应用于int和system.collections.generic.list<int>

ibcadmin 发表于 2014-12-2 10:55:49

a1005341055 发表于 2014-12-2 02:46
有错误   if (Convert.ToInt32(arr) == resultList)   这个错了   说==无法应用于int和system.collecti ...

if(Convert.ToInt32(arr)==resultList)   换成if(Convert.ToInt32(arr【i】)==resultList【i】)   
你是不是一点都不会C#?

a1005341055 发表于 2014-12-2 10:56:25

a1005341055 发表于 2014-12-2 10:46
有错误   if (Convert.ToInt32(arr) == resultList)   这个错了   说==无法应用于int和system.collecti ...

还是不行   有错误   

a1005341055 发表于 2014-12-2 11:00:32

a1005341055 发表于 2014-12-2 10:56
还是不行   有错误

刚刚那个我没有看到后来看到给换了   还是不行的

a1005341055 发表于 2014-12-2 11:07:19

a1005341055 发表于 2014-12-2 11:00
刚刚那个我没有看到后来看到给换了   还是不行的

对不起刚刚我有个没改现在可以正常运行了谢谢   

a1005341055 发表于 2014-12-2 11:11:12

a1005341055 发表于 2014-12-2 11:07
对不起刚刚我有个没改现在可以正常运行了谢谢

我还想问下如果我要改成窗体模式的我应该改哪些

ibcadmin 发表于 2014-12-2 15:44:58

a1005341055 发表于 2014-12-2 03:11
我还想问下如果我要改成窗体模式的我应该改哪些

光改Console.WriteLine 输出语句就行
页: 1 [2]
查看完整版本: 四则运算程序