C语言实现数字炸弹小游戏语言实现数字炸弹小游戏
本文实例为大家分享了C语言实现数字炸弹小游戏的具体代码,供大家参考,具体内容如下
使用的是C语言
# 内容
#include<stdio.h>
#include<stdlib.h>
int main(){
//变量
char c_TheRequest = 1;//开始界面的字符
int in_Deltar = 1,in_EnteredNumber,in_Sig;//游戏中输入数字及其判定所需要的数字
int in_GivenNum = 0,in_An = 0,in_Bn = 0;//出的数字,和数字区间
int in_Mid1,in_Mid2;//用来交换An、Bn的值以满足An<Bn的中间量
int in_DistantAn,in_DistantBn;//An与Bn离num的距离
int in_TemporaryAnSaver,in_TemporaryBnSaver;//临时用于比较的An、Bn储存器
//开始界面
printf("If you just happen to open the game and do not have the intention to play it.");
printf("You can enter a q to quit or you can enter an s to start the game now!");
scanf("%c",&c_TheRequest);
getchar();
while (c_TheRequest != 's' && c_TheRequest != 'q'){
printf("Please do not enter a irrelevant letter.");
scanf("%c",&c_TheRequest);
getchar();
}
if(c_TheRequest == 'q'){
printf("So sad then.Hope you can play with me next time.");
getchar();
}
//游戏
if(c_TheRequest == 's'){
//输入“数字炸弹”
system("cls");
printf("(^ o ^) # *** NOW LET\'S PLAY! *** # (^ o ^)Attention!You can only enter numbers in the following steps.\nEnter to
start.");
getchar();
system("cls");
printf("Game : The number boom!(Another Life.)");
printf("Rule:");
printf("The first player should enter a number.Then he should give to numbers and guarantee the number above is between
them.");
printf("The rest should guess and enter the numbers.And the one who enter the exact number the first player entered");
printf("is supported to be the winner!");
printf("Please Enter a number to start the game.(You is ought not to expose it to other players.The number should bigger
than 0.)");
printf("__________\b");
while(scanf("%d",&in_GivenNum) != 1 || in_GivenNum < 0){
system("cls");
printf("Please Enter a NUMBER which is bigger than 0.");
printf("num:___________");
getchar();
}
system("cls");
//判定是否为数字
//输入“数字炸弹”所在的区间
printf("And where is the number?Please enter two numbers,and ensure that the number above is between them.");
printf("Additionally,there should be at least 100 numbers between the two numbers you will enter.");
do{
printf("num = %d",in_GivenNum);
printf("A:__________");
while(scanf("%d",&in_An)!=1){
printf("Please Enter a NUMBER which is bigger or smaller than the \"num\"!!!!");
printf("A:__________");