c#编程 求设计10道四则运算的题

来源:百度知道 编辑:UC知道 时间:2024/06/15 01:45:50
设计一道计算两个两位数的四则远算,该两位数由随机产生.一位学生做这些题,每题10分,计算该生的成绩.

分太少了,要写一段代码的说~

很简单,只是需要加分,0分谁代你写???

using System;

namespace 四则运算
{
/// <summary>
/// Class1 的摘要说明。
/// </summary>
class Class1
{
/// <summary>
/// 应用程序的主入口点。
/// </summary>
[STAThread]
static void Main(string[] args)
{
Random r=new Random();
int c;
int d;
string y;
string[] fuhao={"+","-","*","/"};
int count=0;
for(int i=1;i<11;i++)
{
try
{
c=r.Next(9,100);
d=r.Next(9,100);
y=fuhao[r.Next(4)];
Console.WriteLine("第"+i+"题:");
Console.Write(c+y+d+"=");
int x=Convert.ToInt32(Console.ReadLine());
switch(y)
{
case "+":
if(x==c+d)
{
Console.WriteLine("正确");