Created
March 31, 2013 16:55
-
-
Save praserocking/5281276 to your computer and use it in GitHub Desktop.
Elo's rating algorithm
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include<iostream> | |
#include<stdlib.h> | |
#include<math.h> | |
using namespace std; | |
int main() | |
{ | |
int tmp,i; | |
double a[5],qa,qb,e; | |
for(i=0;i<5;i++) | |
a[i]=400; | |
for(int j=0;j<5;j++) | |
for(int k=j+1;k<5;k++) | |
{ | |
cout<<"Enter "<<j+1<<" or "<<k+1<<" :"; | |
cin>>tmp; | |
tmp--; | |
qa=pow(10,(a[j]/400)); | |
qb=pow(10,(a[k]/400)); | |
if(j==tmp) | |
{ | |
e=qa/(qa+qb); | |
cout<<"EA="<<e; | |
a[j]=a[j]+16*(1.0-e); | |
e=qb/(qa+qb); | |
cout<<"EB="<<e<<endl; | |
a[k]=a[k]+16*(-e); | |
} | |
else | |
{ | |
e=qb/(qa+qb); | |
cout<<"EB="<<e; | |
a[k]=a[k]+16*(1.0-e); | |
e=qa/(qa+qb); | |
cout<<"EA="<<e<<endl; | |
a[j]=a[j]+16*(-e); | |
} | |
} | |
for(i=0;i<5;i++) | |
{ | |
cout<<"Rating for "<< i+1<<":"<<a[i]<<endl; | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment