请程序员进来帮下忙

来源:百度知道 编辑:UC知道 时间:2024/06/06 12:41:08
假如有21根火柴,A和B轮流拿火柴,每次可以拿1-4根。直到拿最后一根火柴的人输(也就是A或B)...
请设计一套程序:先拿的火柴的人,最后一定输的程序..
谢谢

#include <stdio.h>
#include <conio.h>
#include <float.h>
#include <math.h>
#define TOTAL_MUN 21
#define MOD_NUM 4
#define FORMAT_STR_1 "总共有%d\r\n"
#define FORMAT_STR_2 "\r\n\r\n你赢了!\r\n\r\n"
#define FORMAT_STR_3 "--------第%d轮开始--------\r\n\
对方拿走%d还剩%d\t本轮你应拿 ==>> %d\r\n\
请输入你要拿走的数目 ( 1- %d )\r\n"
#define FORMAT_STR_4 "你输了!"
#define FORMAT_STR_5 "你拿走%d还剩%d\r\n--------第%d轮结束--------\r\n"
#define FORMAT_STR_6 "\r\n输入'q'退出, 输入'y'继续 \r\n"
void game()
{
system("cls");
int betake , sugnum ,total = TOTAL_MUN , i = 1 ;
printf(FORMAT_STR_1,total);
do{
betake = rand() % MOD_NUM;
betake = betake == 0 ? 1 : betake;
total -= betake;
if(total <= 0