c语言if无法激活 - 爱问答

(爱问答)

c语言if无法激活

我用VS做的,代码如下:

(这里把所有的空格都删了,实际语法是正确的,某些操作部分没有写)


#include<stdio.h>  //标准输入、输出函数库

#include<stdlib.h>  //标准函数库

#include<string.h>  //字符串函数库

#include<time.h>  //时间处理函数库

#include<windows.h> //系统操作函数库

#include<dos.h>

#include<conio.h> //屏幕操作函数库

 

#define HELP1 "+---------------=========================Help=========================-----------------+ "

#define HELP2 "| This is a turn-based game.                                                           | "

#define HELP3 "| You will play with computer.                                                         | "

#define HELP4 "| You just have to kill him.                                                           | "

#define HELP5 "| In the process, you can cause harm to the other person, or return blood to yourself. | "

#define HELP6 "| Maximum 3 health per person.                                                         | "

#define HELP7 "+---------------=======================Start Game!====================-----------------+ a"  //设置宏函数——帮助内容

#define UD "****************************************************************************************"

#define GAMEOVER "*-------------=========================GAME OVER========================---------------* "

#define YOUWIN "*--------------========================YOU WIN!========================----------------* "

int bloodp = 3; //设置玩家血量

int usep;  //设置玩家选择项

int p;  //设置玩家使用选项

 

int bloodc = 3; //设置电脑血量

int usec;  //设置电脑选择项

int c;  //设置玩家使用选项

 

void main()

{

system("color F9");

while(1) //循环,避免触发帮助后退出程序

{

printf("Welcome to“Triple kill” ");

printf("Enter “1”to get help Enter “2” to start game. ");  //欢迎语

 

int a; //设置选项输入变量

 

a = getch(); //录入选项

 

if( a == 1 ) //触发帮助内容机制

{

printf(HELP1);

printf(HELP2);

printf(HELP3);

printf(HELP4);

printf(HELP5);

printf(HELP6);

printf(HELP7);  //调用宏函数

}

 

if( a == 2 ) //触发游戏开始

{

 

system("clear");  //清屏

 

printf("Hello! I'm a computer.I'll kill you! a");

 

while(1 == 1) //反复循环直至结束

{

if(bloodp == 0 || bloodc == 0) //判定结束机制

break;

 

printf("Tips:“1” to use rock,“2” to use paper,“3” to use scissors. ");  //提示

 

usep = getch();  //等待玩家选择

 

switch(usep)  //触发玩家语句

{

case 1 :

printf("Player use rock! a");

break;

case 2 :

printf("Player use paper! a");

break;

default:

printf("Player use scissors! a");

}

 

srand( (unsigned) time (NULL) ); //调取时间值,决定电脑回合

 

usec = rand() % 2;

 

switch(usec)  //触发电脑语句

{

case 1 :

printf("Computer use rock! a");

break;

case 2 :

printf("Computer use paper! a");

break;

default:

printf("Computer use scissors! a");

}

}

 

if(bloodp == 0)

{

printf(UD);

printf(GAMEOVER);

printf(UD);

}

if(bloodc == 0)

{

printf(UD);

printf(YOUWIN);

printf(UD);

}

Sleep(10000);

break;

}

}

}

可是输出是这样的:(输入1或2都是这样的,if无法激活)

c语言if无法激活


相关标签:c语言

下一篇:Solidworks2019如何卸掉CAM插件

上一篇:我想让表格中AD5的数据+Q5的数据,如果不等呈现红色,该怎么处理,那位老师知道

热门标签:
excel 网盘 破解 word dll
最新更新:
微软重新评估新的Outlook的使用时机 联想推出搭载联发科Helio G80芯片组的Tab M9平板 英特尔创新大赛时间确定! 微软Edge浏览器在稳定渠道中推出Workspaces功能 英伟达RTX4060TiGPU推出MaxSun动漫主题! 谷歌地图为用户提供了街景服务! GameSir 在T4 Kaleid中推出了一款出色的控制器! 微软开始在Windows 11 中测试其画图应用程序的新深色模式! LG电子推出全球首款无线OLED电视 英伟达人工智能芯片崭露头角! Steam Deck可以玩什么游戏-Steam Deck价格限时优惠 雷蛇推出CobraPro鼠标 Kindle电子阅读器可以访问谷歌商店吗 Windows10如何加入组策略 window10图片查看器怎么没有了?