/* 1996 ACM North Central Regional Programming Contest Problem E -- Transferable voting Ed Karrels, November 1996 */ int ncand, nvoters, v[100][5]; typedef struct { int cand; int nvotes; } Rank; int CompareRank(const void *a, const void *b) { return ((Rank*)b)->nvotes - ((Rank*)a)->nvotes; } void Tally(Rank ranking[5]) { int i, tally[5] = {0}; for (i=0; i ncand) return 0; if (voted[a[i]-1]) return 0; voted[a[i]-1] = 1; } return 1; } void Elim(int cand) { int i, j; for (i=0; i nvoters) { printf(" Candidate %d is elected.\n", ranking[0].cand); break; } tied = 1; for (i=0; i