解题思路:
注意事项:
参考代码:
#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",×[i].p1,×[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 人评分
C语言训练-计算:t=1-1/(2*2)-1/(3*3)-...-1/(m*m) (C语言代码)浏览:784 |
【密码】 (C语言代码)浏览:333 |
C语言训练-排序问题<1> (C语言代码)浏览:601 |
求圆的面积 (C语言代码)浏览:1270 |
sizeof的大作用 (C语言代码)浏览:1450 |
2005年春浙江省计算机等级考试二级C 编程题(2) (C语言代码)浏览:575 |
C语言程序设计教程(第三版)课后习题8.2 (C语言代码)浏览:1034 |
C语言程序设计教程(第三版)课后习题10.1 (C语言代码)浏览:771 |
C语言程序设计教程(第三版)课后习题6.5 (C语言代码)浏览:496 |
孤独的骑士 (C语言代码)浏览:1368 |