1)程序首先随机产生两个1~10之间的正整数,在屏幕上打印出问题,例如: 6*7= 然后让学生输入答案。程序检查学生输入的答案是否正确。若正确,则打印“Right”,然后问下一个问题;否则打印.
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=?
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("输入结果有误,请重新输入:");
}
}
}
}
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("输入结果有误,请重新输入:");
}
}
}
}
楼主,这道题你写出来了吗,救救孩子吧
#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;
}