团体天梯赛 L1-044. 稳赢

本文介绍了一个猜拳游戏程序的设计思路,该程序能够根据对手的选择进行回应以达到稳赢的效果,同时为了增加趣味性,每K次让一次平局。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

大家应该都会玩“锤子剪刀布”的游戏:两人同时给出手势,胜负规则如图所示:

现要求你编写一个稳赢不输的程序,根据对方的出招,给出对应的赢招。但是!为了不让对方输得太惨,你需要每隔K次就让一个平局。

输入格式:

输入首先在第一行给出正整数K(<=10),即平局间隔的次数。随后每行给出对方的一次出招:“ChuiZi”代表“锤子”、“JianDao”代表“剪刀”、“Bu”代表“布”。“End”代表输入结束,这一行不要作为出招处理。

输出格式:

对每一个输入的出招,按要求输出稳赢或平局的招式。每招占一行。

输入样例:
2
ChuiZi
JianDao
Bu
JianDao
Bu
ChuiZi
ChuiZi
End
输出样例:
Bu
ChuiZi
Bu
ChuiZi
JianDao
ChuiZi
Bu

#include<stdio.h>
#include <string.h>
int main(){
  
  int num;
  char str[10]={""};
  int count=0;
  int i;
  char str1[10]={"ChuiZi"};
    char str2[10]={"JianDao"};
    char str3[10]={"Bu"};
    char str4[10]={"End"};
  scanf("%d",&num);
  num++;
  
  for(i=0; ;i++){
    
    scanf("%s",str);
       count++;
    if(!strcmp(str,str4))
      break;
    
    if(!strcmp(str,str1)){
    
      if(count%num==0){
        printf("ChuiZi\n");
      
      }
      
      else{
      printf("Bu\n");
    
      }
    }
    else if(!strcmp(str,str3)){
    
        if(count%num==0){
        printf("Bu\n");
    
      }
      
      else{
    printf("JianDao\n");
    
      }
        
    }
    else if(!strcmp(str,str2)){
    
        if(count%num==0){
        printf("JianDao\n");
      
      }
      
      else{
         printf("ChuiZi\n");
      
      }
        
    
    }
    
    
}
  
  return 0;
} 

root@ubuntu22:~/FPGAs_AdaptiveSoCs_Unified_2024.1_0522_2023# ls api-ms-win-core-console-l1-1-0.dll api-ms-win-core-synch-l1-1-0.dll bin api-ms-win-core-datetime-l1-1-0.dll api-ms-win-core-synch-l1-2-0.dll concrt140.dll api-ms-win-core-debug-l1-1-0.dll api-ms-win-core-sysinfo-l1-1-0.dll data api-ms-win-core-errorhandling-l1-1-0.dll api-ms-win-core-timezone-l1-1-0.dll installLibs.sh api-ms-win-core-file-l1-1-0.dll api-ms-win-core-util-l1-1-0.dll lib api-ms-win-core-file-l1-2-0.dll api-ms-win-crt-conio-l1-1-0.dll msvcp140_1.dll api-ms-win-core-file-l2-1-0.dll api-ms-win-crt-convert-l1-1-0.dll msvcp140_2.dll api-ms-win-core-handle-l1-1-0.dll api-ms-win-crt-environment-l1-1-0.dll msvcp140.dll api-ms-win-core-heap-l1-1-0.dll api-ms-win-crt-filesystem-l1-1-0.dll payload api-ms-win-core-interlocked-l1-1-0.dll api-ms-win-crt-heap-l1-1-0.dll scripts api-ms-win-core-libraryloader-l1-1-0.dll api-ms-win-crt-locale-l1-1-0.dll tps api-ms-win-core-localization-l1-2-0.dll api-ms-win-crt-math-l1-1-0.dll ucrtbase.dll api-ms-win-core-memory-l1-1-0.dll api-ms-win-crt-multibyte-l1-1-0.dll vccorlib140.dll api-ms-win-core-namedpipe-l1-1-0.dll api-ms-win-crt-private-l1-1-0.dll vcruntime140_1.dll api-ms-win-core-processenvironment-l1-1-0.dll api-ms-win-crt-process-l1-1-0.dll vcruntime140.dll api-ms-win-core-processthreads-l1-1-0.dll api-ms-win-crt-runtime-l1-1-0.dll xsetup api-ms-win-core-processthreads-l1-1-1.dll api-ms-win-crt-stdio-l1-1-0.dll xsetup.exe api-ms-win-core-profile-l1-1-0.dll api-ms-win-crt-string-l1-1-0.dll xsetup.exe.manifest api-ms-win-core-rtlsupport-l1-1-0.dll api-ms-win-crt-time-l1-1-0.dll api-ms-win-core-string-l1-1-0.dll api-ms-win-crt-utility-l1-1-0.dll 这是linux版本还是windows版本
最新发布
07-19
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值