Ultraviolet A 10194-Football

Source: Internet
Author: User

It is a simulated question. It is a little troublesome and basically simple, but it should be noted that the question is a bit problematic. It is case-insensitive when sorting 6th pieces in Lexicographic Order, it has been pitted twice ~~~

The Code is as follows:

# Include <stdio. h> # include <string. h> # include <stdlib. h> # include <ctype. h> char tourname [1000 + 2], game [1000] [100]; typedef struct Team {int B, c, d, e, f, g, h, I; char team [40];} TT; TT t [200 + 2]; int struct_cmp (const void * B, const void * a) // qsort multi-condition sorting {int I; TT * c = (TT *) a; TT * d = (TT *) B; if (c-> B! = D-> B) return c-> B-d-> B; else if (c-> d! = D-> d) return c-> d; else if (c-> g! = D-> g) return c-> g-d-> g; else if (c-> h! = D-> h) return c-> h-d-> h; else if (c-> c! = D-> c) return d-> c; else {char s1 [40] = {'\ 0 '}, s2 [40] = {'\ 0'}; strcpy (s1, d-> team); strcpy (s2, c-> team); for (I = 0; I <strlen (c-> team); I ++) s2 [I] = toupper (s2 [I]); // case insensitive, therefore, we need to convert all the data into uppercase or lowercase letters and then compare them for (I = 0; I <strlen (d-> team); I ++) s1 [I] = toupper (s1 [I]); return strcmp (s1, s2) ;}} void addsort (int T, int G) {int I, j, numa, numb, fa, fb; char ma [40], mb [40]; for (I = 0; I <T; I ++) {t [I]. B = t [I]. c = t [I]. d = t [I]. e = t [I]. f = t [I]. G = t [I]. h = t [I]. I = 0 ;}for (I = 0; I <G; I ++) {sscanf (game [I], "% [^ #] # % d @ % d # % [^ \ n]", ma, & numa, & numb, mb); for (j = 0; j <T; j ++) if (strcmp (t [j]. team, ma) = 0) {fa = j; break;} for (j = 0; j <T; j ++) if (strcmp (t [j]. team, mb) = 0) {fb = j; break;} t [fa]. c + = 1; t [fb]. c + = 1; t [fa]. h + = numa; t [fb]. h + = numb; t [fa]. I + = numb; t [fb]. I + = numa; t [fa]. g = t [fa]. h-t [fa]. i; t [fb]. g = t [fb]. h-t [fb]. i; if (numa> numb) {t [fa]. d ++; t [fb]. f ++; t [Fa]. B + = 3;} else if (numa <numb) {t [fa]. f ++; t [fb]. d ++; t [fb]. B + = 3;} else {t [fa]. e ++; t [fb]. e ++; t [fa]. B ++; t [fb]. B ++ ;}}int main () {# ifdef test freopen ("sample.txt", "r", stdin); freopen ("out.txt", "w ", stdout); # endif int N, T, G; int I; scanf ("% d", & N); getchar (); while (N --) {gets (tourname); scanf ("% d", & T); getchar (); for (I = 0; I <T; I ++) gets (t [I]. team); scanf ("% d", & G); getchar (); for (I = 0; I <G; I ++) Gets (game [I]); addsort (T, G); qsort (t, T, sizeof (t [0]), struct_cmp ); printf ("% s \ n", tourname); for (I = 0; I <T; I ++) printf ("% d) % s % dp, % dg (% d-% d), % dgd (% d-% d) \ n ", I + 1, t [I]. team, t [I]. b, t [I]. c, t [I]. d, t [I]. e, t [I]. f, t [I]. g, t [I]. h, t [I]. i); if (N! = 0) puts ("");} return 0 ;}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.