坚果


私信TA

用户名:dotcpp0615334

访问量:3525

签 名:

等  级
排  名 113
经  验 7719
参赛次数 0
文章发表 43
年  龄 0
在职情况 学生
学  校 xx
专  业

  自我简介:

TA的其他文章

解题思路:

注意事项:

参考代码:

#include<stdio.h>

#include<string.h>

//建立结构体

struct play

{

char p1[100];//玩家1

char p2[100];//玩家2

}times[100];//玩的次数


int main()

{

int n;

char p1[100],p2[100];

scanf("%d",&n);

int i;

//输入

for(i=0;i<n;i++)

{

    scanf("%s %s",&times[i].p1,&times[i].p2);

}

//遍历比较

for(i=0;i<n;i++)

{

    if(!strcmp(times[i].p1,times[i].p2))

     {

          printf("Tie\n");

     }

     else if(!strcmp(times[i].p1,"Rock")&&!strcmp(times[i].p2,"Scissors"))

     {

        printf("Player1\n");

     }

     else if(!strcmp(times[i].p1,"Scissors")&&!strcmp(times[i].p2,"Paper"))

     {

          printf("Player1\n");

     }

     else if(!strcmp(times[i].p1,"Paper")&&!strcmp(times[i].p2,"Rock"))

     {

        printf("Player1\n");

     }

     else printf("Player2\n");

}

return 0; 

}


 

0.0分

5 人评分

看不懂代码?想转换其他语言的代码? 或者想问其他问题? 试试问问AI编程助手,随时响应你的问题:

编程语言转换

万能编程问答  

代码解释器

代码纠错

SQL生成与解释

  评论区