From d4a95a806fbdced06b8518518b18a776f188151c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=98=E5=8D=8E?= Date: Mon, 23 Aug 2021 06:21:49 +0000 Subject: [PATCH] =?UTF-8?q?CI=E6=B5=8B=E8=AF=95=E5=8D=95=EF=BC=8C=E8=AF=B7?= =?UTF-8?q?=E5=8B=BF=E5=90=88=E5=85=A5!?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- test0823.c | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 test0823.c diff --git a/test0823.c b/test0823.c new file mode 100644 index 0000000..9cc86e5 --- /dev/null +++ b/test0823.c @@ -0,0 +1,32 @@ +#include +#include +#include +int main() +{ + int d1, d2, c1, c2, i, j; + c1 = c2 = 0; /*初始化*/ + srand((unsigned)time(NULL)); + rand(); /*初始化随机数产生器*/ + for(i=1; i<=100; i++) + { /*模拟游戏过程*/ + d1 = d2 = 0; + for(j=1; j<=6; j++) + { /*两个人轮流掷骰子*/ + d1 = d1+rand()+1; + d2 = d2+rand()+1; + } + if(d1>d2) + c1++; /*累加获胜盘数*/ + else if(d1c2) /*输出最终获胜者信息*/ + printf("\nThe first win.\n"); + else + if (c1