Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- #include <math.h>
- using namespace std;
- void rendez(string csapat[16],int ep[16],string csapatKereszt[16],double hv[16]){
- double tmp[16];
- for(int i=0;i<16;i++){
- tmp[i]=hv[i];
- }
- int index[16];
- for(int j=0;j<16;j++){
- int maxindex=0;
- for(int i=1;i<16;i++){
- if(tmp[i]>tmp[maxindex]){
- maxindex=i;
- }
- }
- index[j]=maxindex;
- tmp[maxindex]=0;
- }
- for(int i=0;i<16;i++){
- cout << csapat[i] << "\t" << ep[i] << "\t" << csapatKereszt[index[i]] << "\t" << hv[index[i]] << endl;
- }
- }
- void wiki2matrix(int kereszt[16][16],int pont[16][16],int oszloposszeg[16],double L[16][16]){
- int i,j;
- for(i=0;i<16;i++)
- for(j=0;j<16;j++){
- if(kereszt[i][j]==1)
- ++pont[i][j];
- else if(kereszt[i][j]==2){
- ++pont[i][j];
- ++pont[j][i];
- }
- else if(kereszt[i][j]==3)
- ++pont[j][i];
- }
- cout << "Az X pontot szerez Y-tol matrix:" << endl;
- for(i=0;i<16;i++){
- for(j=0;j<16;j++){
- cout << pont[i][j] << " ";
- }
- cout << endl;
- }
- cout << endl;
- cout << "Sor és oszlop összegekkel:" << endl;
- for(i=0;i<16;i++){
- int o=0;
- for(j=0;j<16;j++){
- cout << pont[i][j] << "\t";
- o+=pont[i][j];
- }
- cout << o << endl;
- }
- for(i=0;i<16;i++){
- int o=0;
- for(j=0;j<16;j++){
- o+=pont[j][i];
- }
- cout << o << "\t";
- oszloposszeg[i]=o;
- }
- cout << endl;
- cout << "A linkmatrix" << endl;
- for(i=0;i<16;i++){
- cout << "{";
- for(j=0;j<16;j++){
- if(oszloposszeg[j]!=0){
- cout << (double)(pont[i][j]*(1.0/oszloposszeg[j])) << ", ";
- L[i][j]=(double)(pont[i][j]*(1.0/oszloposszeg[j]));
- }
- else{
- cout << pont[i][j] << ", ";
- L[i][j]=pont[i][j];
- }
- }
- cout << "}," << endl;
- }
- }
- int main(){
- int kereszt[16][16]={
- {0, 2, 1, 0, 0, 0, 2, 1, 0, 0, 3, 2, 3, 1, 2, 3},
- {1, 0, 1, 0, 0, 1, 1, 1, 1, 1, 3, 3, 1, 0, 3, 1},
- {1, 0, 0, 1, 0, 3, 2, 3, 0, 0, 1, 1, 2, 1, 1, 1},
- {3, 1, 3, 0, 2, 0, 3, 0, 3, 2, 3, 2, 0, 2, 0, 3},
- {3, 1, 1, 1, 0, 2, 1, 0, 2, 1, 0, 2, 1, 0, 1, 0},
- {2, 1, 1, 1, 0, 0, 2, 1, 1, 1, 0, 0, 1, 1, 1, 0},
- {0, 0, 2, 1, 2, 2, 0, 2, 0, 0, 1, 3, 2, 1, 1, 3},
- {0, 1, 0, 2, 1, 3, 0, 0, 3, 1, 2, 0, 2, 1, 2, 3},
- {1, 2, 2, 0, 2, 0, 1, 3, 0, 3, 2, 0, 3, 0, 0, 0},
- {1, 1, 2, 0, 3, 0, 1, 1, 3, 0, 3, 2, 3, 0, 0, 1},
- {1, 0, 0, 1, 1, 3, 0, 1, 1, 1, 0, 0, 2, 2, 1, 1},
- {3, 0, 0, 3, 0, 2, 2, 3, 0, 1, 2, 0, 3, 1, 2, 2},
- {0, 3, 0, 2, 2, 3, 0, 3, 3, 0, 1, 3, 0, 1, 3, 2},
- {3, 3, 0, 1, 2, 3, 3, 0, 3, 1, 0, 2, 0, 0, 0, 3},
- {0, 2, 2, 1, 1, 0, 0, 1, 1, 2, 0, 3, 0, 1, 0, 3},
- {3, 1, 2, 1, 3, 3, 1, 0, 1, 2, 0, 0, 0, 1, 2, 0}};
- int pont[16][16];
- int oszloposszeg[16];
- int i,j;
- double L[16][16];
- for(i=0;i<16;i++){
- for(j=0;j<16;j++){
- pont[i][j]=0;
- }
- }
- wiki2matrix(kereszt,pont,oszloposszeg,L);
- string csapat[16]={"Győri ETO","MTK Budapest","Videoton","Ferencváros","Debreceni VSC","Diósgyőr","Budapest Honvéd","Kaposvári Rákóczi","Paksi FC","Újpest","Kecskeméti TE","Haladás","Pécsi MFC","Lombard Pápa","Egri FC","BFC Siófok"};
- int ep[16]={50,41,38,35,33,31,29,29,29,28,27,27,25,23,12,10};
- string csapatKereszt[16]={"Budapest Honvéd","Debreceni VSC","Diósgyőr","Egri FC","Ferencváros","Győri ETO","Haladás","Kaposvári Rákóczi","Kecskeméti TE","Lombard Pápa","MTK Budapest","Paksi FC","Pécsi MFC","BFC Siófok","Újpest","Videoton"};
- double hv[16], h[16];
- for(i=0;i<16;i++){
- hv[i]=1.0/16;
- h[i]=0.0;
- }
- double reginorma = 0.0, regiosszeg = 0.0;
- bool amig=true;
- while(amig){
- for(i=0;i<16;i++){
- for(j=0;j<16;j++){
- h[i]+= L[i][j] * hv[j];
- }
- cout << h[i] << endl;
- }
- double osszeg = 0.0;
- for(i=0;i<16;i++){
- osszeg += (hv[i] - h[i]) * (hv[i] - h[i]);
- }
- double norma = sqrt(osszeg);
- cout << "Norma= " << norma << endl;
- if(norma < 0.000000000001){
- amig = false;
- cout << endl;
- double osszegEll = 0.0;
- for (int i = 0; i < 16; ++i) {
- osszegEll += h[i];
- }
- cout << "osszegell = " << osszegEll << endl;
- }
- double d=0.87;
- osszeg=0.0;
- for (int i = 0; i < 16; ++i) {
- hv[i] = d * h[i] + (1.0 - d) / 16;
- osszeg += hv[i];
- h[i] = 0.0;
- }
- cout << "osszeg: " << osszeg << endl;
- if (osszeg == regiosszeg && norma == reginorma){
- amig = false;
- for (int i = 0; i < 16; ++i) {
- cout << hv[i] << endl;
- }
- }
- reginorma = norma;
- regiosszeg = osszeg;
- }
- rendez(csapat,ep,csapatKereszt,hv);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement