From aabd2bca7bc438cfaca4a9f1f6334f2a6ab13279 Mon Sep 17 00:00:00 2001 From: Baoshuo Date: Fri, 8 Nov 2024 23:21:29 +0800 Subject: [PATCH] =?UTF-8?q?=E3=80=90=E9=A2=9D=E5=A4=96=E7=BB=83=E4=B9=A0?= =?UTF-8?q?=E3=80=91=E9=80=89=E6=8B=A9=E7=BB=93=E6=9E=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 【额外练习】选择结构/7-58 选择-汉笨笨拜师3.c | 48 ++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 【额外练习】选择结构/7-58 选择-汉笨笨拜师3.c diff --git a/【额外练习】选择结构/7-58 选择-汉笨笨拜师3.c b/【额外练习】选择结构/7-58 选择-汉笨笨拜师3.c new file mode 100644 index 0000000..c5e4a1a --- /dev/null +++ b/【额外练习】选择结构/7-58 选择-汉笨笨拜师3.c @@ -0,0 +1,48 @@ +#include +#include + +char a[3], b[3]; + +int main() { + scanf("%s%s", a, b); + + if (a[0] == 'J') { + strcpy(a, "11"); + } else if (a[0] == 'Q') { + strcpy(a, "12"); + } else if (a[0] == 'K') { + strcpy(a, "13"); + } else if (a[0] == 'A') { + strcpy(a, "14"); + } else if (a[0] == '2') { + strcpy(a, "15"); + } + + if (b[0] == 'J') { + strcpy(b, "11"); + } else if (b[0] == 'Q') { + strcpy(b, "12"); + } else if (b[0] == 'K') { + strcpy(b, "13"); + } else if (b[0] == 'A') { + strcpy(b, "14"); + } else if (b[0] == '2') { + strcpy(b, "15"); + } + + int a1 = a[0] - '0', a2 = a[1] - '0'; + int b1 = b[0] - '0', b2 = b[1] - '0'; + + int a0 = a2 * 10 + a1; + int b0 = b2 * 10 + b1; + + if (a0 == b0) { + printf("No winner\n"); + } else if (a0 > b0) { + printf("Alice win\n"); + } else { // a0 < b0 + printf("Bob win\n"); + } + + return 0; +}