#include源文件

// 猜字小游戏2.cpp: 定义控制台应用程序的入口点。
//


#include "stdafx.h"
#include<stdio.h>
#include<stdlib.h>
#include<time.h>
int getRandNumber();
void guessResult(int counter);
void Guessthenumber();
int getRandNumber()
{
srand((unsigned int)time(0));
return (rand() % 100);
}
void guessResult(int counter)          //判断猜测次数
{
switch (counter)
{
case 1:
case 2:
case 3:
printf("Are you genius?\n");
break;
case 4:
case 5:
case 6:
printf("Are you want to continue\n");
break;
case 7:
case 8:
case 9:
printf("Just so so\n");
break;
default:
printf("Are you want to guess me\n");
break;
}
}
void Guessthenumber()              //猜字函数
{
int myanswer;
int counter = 1;
int Randnumber = getRandNumber();
while (counter)
{
printf("please enter your guess number\n");
scanf_s("%d", &myanswer);
if (myanswer > Randnumber)
{
printf("Too bigger!\n");
}
else
if (myanswer < Randnumber)
{
printf("Too small!\n");
}
else
if (myanswer == Randnumber)
{

printf("That is correct!\n");

                                                       break;//这里可能有点问题

}
counter++;
guessResult(counter);
}
}
int main(void)
{
printf("欢迎来到猜字小游戏\n");
Guessthenumber();
return 0;

}

/*这个程序出现了一点问题就是当我输入的数字正确的时候,运行窗口就立即弹出*/

/* 哪位可以帮忙改一下*/


没有更多推荐了,返回首页