static void Mainstring args string i = nulldo ConsoleWritequot请输入一个整数范围为1~100\n如果要退出,请输入0否则输入1quoti = ConsoleReadLineif iTrimEqualsquot0quot return。
num=randi100,1 1i=0while ilt3elseifanumdisp #39High#39i=i+1else end if i==3disp #39You lose#39end include ltstdioh int mainprintfquotenter the integer you guessquotscanfquot%dquot。
public static void mainStringargs Scanner sc=new ScannerSysteminint x=intMathrandom*100生成一个0~100的随机数 int y=1quot已生成0~100的随机整数,请输入您所猜的。
include quotstdiohquotinclude includeltstdlibh void Guessint magic, int guess static int c = 0c++if magic == guess printfquot\n你猜对了\n你一共猜了%d次quot, cexit0 if magic lt。
include ltstdioh include ltstdlibh include include ltctypeh define MAX_N 100 随机整数的上限 define MIN_N 1 随机整数的下限 int gamevoid 猜数字的游戏函数,返回值是猜数字的次数。