2 qq 34015982 qq_34015982 于 2016.02.19 09:44 提问

小学生计算机辅助教学系统(控制结构程序设计)1 .

   1)程序首先随机产生两个1~10之间的正整数,在屏幕上打印出问题,例如:       6*7=       然后让学生输入答案。程序检查学生输入的答案是否正确。若正确,则打印“Right”,然后问下一个问题;否则打印.

4个回答

caozhy
caozhy   Ds   Rxr 2016.02.19 09:59
已采纳
 5*2=?10
right
9*4=?36
right
6*4=?24
right
7*10=?70
right
8*4=?32
right
2*4=?8
right
2*10=?20
right
8*9=?72
right
1*2=?2
right
9*3=?28
wrong
2*8=?16
right
4*3=?11
wrong
10*10=?100
right
3*1=?
caozhy
caozhy   Ds   Rxr 2016.02.19 09:49
 #include <stdio.h>
#include <stdlib.h>
#include <time.h>

int main()
{
    srand((unsigned)time(NULL));
    while (true)
    {
        int x = rand() % 10 + 1;
        int y = rand() % 10 + 1;
        printf("%d*%d=?", x, y);
        int z;
        scanf("%d", &z);
        if (x * y == z) printf("right\n"); else printf("wrong\n");
    }
    return 0;
}
huqiqi1234
huqiqi1234   2016.02.19 10:35

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
Random random = new Random();
while (true)
{
Test(random);
}
}

    private static void Test(Random random)
    {
        int x1 = random.Next(10);
        int x2 = random.Next(10);
        string xy = x1.ToString() + " + " + x2.ToString() + " = ";
        Console.WriteLine(xy);
        Console.Write("请输入结果:");
        string result = Console.ReadLine();
        try
        {
            while ((x1 + x2) != Convert.ToInt16(result))
            {
                Console.WriteLine("输入结果有误,请重新输入:");
                result = Console.ReadLine();
            }
            Console.WriteLine("Right");
        }
        catch (Exception ex)
        {
            Console.WriteLine("输入结果有误,请重新输入:");
        }
    }
}

}

huqiqi1234
huqiqi1234   2016.02.19 10:39

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
Random random = new Random();
while (true)
{
Test(random);
}
}

    private static void Test(Random random)
    {
        int x1 = random.Next(10);
        int x2 = random.Next(10);
        string xy = x1.ToString() + " * " + x2.ToString() + " = ";
        Console.WriteLine(xy);
        Console.Write("请输入结果:");
        string result = Console.ReadLine();
        try
        {
            while ((x1 * x2) != Convert.ToInt16(result))
            {
                Console.WriteLine("输入结果有误,请重新输入:");
                result = Console.ReadLine();
            }
            Console.WriteLine("Right");
        }
        catch (Exception ex)
        {
            Console.WriteLine("输入结果有误,请重新输入:");
        }
    }
}

}

Csdn user default icon
上传中...
上传图片
插入图片
准确详细的回答,更有利于被提问者采纳,从而获得C币。复制、灌水、广告等回答会被删除,是时候展现真正的技术了!