From b3c8e3e7dd474acb760b30fdca0d494c297cbbbb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=98=E5=8D=8E?= Date: Mon, 30 Aug 2021 08:57:01 +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 --- test0830.c | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 test0830.c diff --git a/test0830.c b/test0830.c new file mode 100644 index 0000000..9cc86e5 --- /dev/null +++ b/test0830.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