C#判断语句的问题

来源:百度知道 编辑:UC知道 时间:2024/05/30 18:27:18
写了一个数再产生一个随机数判断是否与该数相等,若是则循环再一次再判断一次,判断为假则执行下面的语句请问要怎么写呀??

我的程序,哥们儿看看吧!

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

namespace 随机数
{
class Program
{
static void Main(string[] args)
{
int target = 5;
Random random = new Random();
int num = random.Next(1,10);
if (num == target) { Console.WriteLine("OK ! Find the Number "+target); }
else
{
do
{
Console.WriteLine("the Random Num is "+num);
num = random.Next(1, 10);

} while (num != target);
Console.WriteLine("OK ! Find the Number "+num);
}
}
}
}

int num;
do
{
Random r=new Random();
}while(r.Next()==num)

int target = 200;
Random random = new Ran