Advertisement
Guest User

Untitled

a guest
Nov 4th, 2018
310
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.21 KB | None | 0 0
  1. #include<iostream>
  2. #include<string>
  3. #include<iomanip>
  4. using namespace std;
  5.  
  6. int main()
  7. {
  8.     int n,k;
  9.     bool first=true;
  10.     while(cin>>n){
  11.         if(n==0)
  12.             break;
  13.         cin>>k;
  14.         int win[1000]={0};
  15.         int lose[1000]={0};
  16.         int sum[1000]={0};
  17.         int p1,p2;
  18.         string m1,m2;
  19.         int i=0;
  20.         while(cin>>p1>>m1>>p2>>m2){
  21.             ++i;
  22.  
  23.             if((m1=="paper"&&m2=="rock")||(m1=="rock"&&m2=="scissors")||(m1=="scissors"&&m2=="paper")){
  24.                 ++win[p1];
  25.                 ++lose[p2];
  26.                 ++sum[p1];
  27.                 ++sum[p2];
  28.             }
  29.             else if((m2=="paper"&&m1=="rock")||(m2=="rock"&&m1=="scissors")||(m2=="scissors"&&m1=="paper")){
  30.                 ++win[p2];
  31.                 ++lose[p1];
  32.                 ++sum[p1];
  33.                 ++sum[p2];
  34.             }
  35.  
  36.             if(i==k*n*(n-1)/2)
  37.                 break;
  38.         }
  39.  
  40.         if(!first)
  41.             cout<<endl;
  42.         for(int j=1;j<=n;++j)
  43.             if(sum[j]==0)
  44.                 cout<<"-"<<endl;
  45.             else
  46.                 cout<<fixed<<setprecision(3)<<(double)win[j]/sum[j]<<endl;
  47.  
  48.         first=false;
  49.     }
  50.     return 0;
  51. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement