1019石头、剪刀、布

来源:互联网 发布:vlengine是什么软件 编辑:程序博客网 时间:2024/04/27 21:28
#include <iostream>  using namespace std;  int main()  {      int t;      cin>>t;      int a,b,n;      char c1,c2;      for(int i=0;i<t;i++)      {          a=0;          b=0;            cin>>n;          for(int j=0;j<n;j++)          {              cin>>c1>>c2;              if(c1=='R')              {                  if(c2=='S')                      a++;                  else if(c2=='P')                      b++;                      else if(c2=='R')                      {                          a++;                          b++;                      }              }              else if(c1=='P')              {                  if(c2=='R')                      a++;                  else if(c2=='S')                      b++;                          else if(c2=='p')                      {                          a++;                          b++;                      }              }              else if(c1=='S')              {                if(c2=='P')                  a++;                else if(c2=='R')                  b++;                      else if(c2=='S')                      {                         a++;                         b++;                      }              }          }          if(a>b)             {            cout<<"Player 1"<<endl; }         else if(a<b)              {cout<<"Player 2"<<endl;            }          else if (a==b)       {     cout<<"TIE"<<endl;         }    }      return 0;  }  

0 0
原创粉丝点击