#include #include #include typedef struct team { char jmeno[100]; int odehranych, danych, obdrzenych, vyher, proher, remiz, body; }; typedef struct skor { int host, guest; }; team pole[80]; skor skore[80][80]; int muzstev, M; unsigned max; int index(char *w) { int i = 0; for (; strcmp(w, pole[i].jmeno) != 0 ;++i) ; return i; } void radek() { putchar('+'); for (unsigned i=0; i < max; ++i) putchar('-'); putchar('+'); for (int i = 0; i < muzstev; ++i) { printf("---+"); } putchar('\n'); } bool porovnaj( const team& a, const team& b) { if( a.body != b.body ) return a.body > b.body; if( a.danych - a.obdrzenych != b.danych - b.obdrzenych) return a.danych - a.obdrzenych > b.danych - b.obdrzenych; if( a.danych != b.danych) return a.danych > b.danych; if( a.vyher != b.vyher) return a.vyher > b.vyher; return true; } int main() { scanf("%d\n", &muzstev ); while (muzstev != 0 ) { for (int i=0; i < muzstev; ++i ) { scanf("%s\n", pole[i].jmeno ); } scanf("%d", &M); for(int i = 0; i< muzstev; ++i) for(int j = 0; j< muzstev; ++j) {skore[i][j]. host = -1; } for (int i=0; i < M; ++i) { char x[100], y[100]; scanf("%s - %s ", x, y); int xx, yy; xx = index(x); yy = index(y); scanf("%d:%d\n", &(skore[xx][yy].host), &(skore[xx][yy].guest) ); pole[xx].danych += skore[xx][yy].host; pole[xx].obdrzenych += skore[xx][yy].guest; pole[yy].danych += skore[xx][yy].guest; pole[yy].obdrzenych += skore[xx][yy].host; pole[xx].odehranych++; pole[yy].odehranych++; if ( skore[xx][yy].host > skore[xx][yy].guest ) { pole[xx].vyher++; pole[yy].proher++; } else if ( skore[xx][yy].host < skore[xx][yy].guest ) { pole[yy].vyher++; pole[xx].proher++; } else { pole[xx].remiz++; pole[yy].remiz++; } } max = 0; for (int i = 0; i< muzstev; ++i) { max = ( strlen( pole[i].jmeno ) > max ) ? strlen(pole[i].jmeno) : max; } for (int i = 0; i < muzstev; ++i) { pole[i].body = 3*pole[i].vyher + pole[i].remiz; } std::sort( pole, pole + muzstev, porovnaj); printf("RESULTS:\n"); radek(); putchar('|'); for (unsigned i = 0 ; i < max; ++i) putchar(' '); putchar('|'); for (int i = 0; i < muzstev; ++i) { printf("%c%c%c|", pole[i].jmeno[0], pole[i].jmeno[1], pole[i].jmeno[2]); } putchar('\n'); radek(); for (int i =0; i < muzstev; ++i) { putchar('|'); printf("%s", pole[i].jmeno); for (unsigned j = strlen(pole[i].jmeno); j < max; ++j) putchar(' '); putchar('|'); for(int j=0; j < muzstev; ++j) { if (i == j) printf(" X |"); else if ( skore[i][j].host != -1 ) printf("%d:%d|", skore[i][j].host, skore[i][j].guest ); else printf(" |"); } putchar('\n'); radek(); } int velikosti[8]; for (int i =0; i < 8; ++i) velikosti[i] = 0; if( muzstev > 9) velikosti[ 0]= 1; else velikosti[ 0]= 0; for( int i= 0; i < muzstev; ++i) if( pole[i].odehranych > 9) velikosti[1]= 1; for( int i= 0; i < muzstev; ++i) if( pole[i].vyher > 9) velikosti[2]= 1; for( int i= 0; i < muzstev; ++i) if( pole[i].remiz > 9) velikosti[3]= 1; for( int i= 0; i < muzstev; ++i) if( pole[i].proher > 9) velikosti[4]= 1; for( int i= 0; i < muzstev; ++i) if( pole[i].danych > 99) velikosti[5]= 2; else if( pole[i].danych > 9) velikosti[5]=1; for( int i= 0; i < muzstev; ++i) if( pole[i].obdrzenych > 99) velikosti[6]+= 2; else if( pole[i].obdrzenych > 9) velikosti[6]+=1; for( int i= 0; i < muzstev; ++i) if( pole[i].body > 99) velikosti[7]= 2; else if( pole[i].body > 9) velikosti[7]=1; printf("\nSTANDINGS:\n----------\n"); for (int i = 0; i < muzstev; ++i) { if( i < 9 && velikosti[0] == 1) putchar( ' '); printf("%d. ", i+1); printf("%s", pole[i].jmeno); for (unsigned j = strlen( pole[i].jmeno); j <= max; ++j) putchar(' '); if( pole[i].odehranych < 10 && velikosti[1] == 1) putchar( ' '); printf("%d ", pole[i].odehranych); if( pole[i].vyher < 10 && velikosti[2] == 1) putchar( ' '); printf("%d ", pole[i].vyher); if( pole[i].remiz < 10 && velikosti[3] == 1) putchar( ' '); printf("%d ", pole[i].remiz); if( pole[i].proher < 10 && velikosti[4] == 1) putchar( ' '); printf("%d ", pole[i].proher); // printf(" %d ", velikosti[5]); if( pole[i].danych < 10 && velikosti[5] >= 2) putchar( ' '); if( pole[i].danych < 10 && velikosti[5] >= 1) putchar( ' '); if( pole[i].danych >= 10 && velikosti[5] >= 2) putchar( ' '); if( pole[i].obdrzenych < 10 && velikosti[6] >= 2) putchar( ' '); if( pole[i].obdrzenych < 10 && velikosti[6] >= 1) putchar( ' '); if( pole[i].obdrzenych >= 10 && velikosti[6] >= 2) putchar( ' '); printf("%d:%d ", pole[i].danych, pole[i].obdrzenych); if( pole[i].body < 10 && velikosti[7] == 1) putchar( ' '); printf("%d", pole[i].body); putchar ('\n'); } //nakonec for( int i= 0; i < muzstev; ++i) { pole[i].jmeno[0]= 0; pole[i].odehranych = pole[i].danych = pole[i].obdrzenych = pole[i].vyher = pole[i].proher = pole[i].remiz = pole[i].body = 0; } for( int i= 0; i < M; ++i) for( int j= 0; j < M; ++j) skore[i][j].host = skore[i][j].guest = 0; scanf("%d\n", &muzstev ); } return 0; }