// Two-star problem // Problem 11286 Conformity /* This program is written by Prof. Chua-Huang Huang Department of Information Engineering and Computer Science Feng Chia University Taichung, Taiwan Disclaimer: The programming problem is downloaded from UVa Online Judge (https://uva.onlinejudge.org/). The program solution is provided for helping students to prepare Collegiate Programming Examination (CPE). The author does not guarantee the program is completely correct to pass UVa Online Judge platform or CPE examination platform. This program is not intended for a student to copy only. He/She should practice the programming problem himself/herself. Only use the program solution as a reference. The author is not responsible if the program causes any damage of your computer or personal properties. No commercial use of this program is allowed without the author's written permission. */ #include #include int main(void) { int students; // Number of students; int enrollment[10000][5]; // Maximum 10000 students, each student takes five courses. int selected[10000]; // Indicate the student's course has been selected in a combination. int most_popular; // The combination has the most combination so far. int popular_count; // The count of the most popular combination. int combination; // Number of students with the the current combination. int same; // The same combination. int temp; // Temporary varialbe for swapping course numbers. int i, j, k; // Loop vairables. while (1) { // Continue, when the input student number is not zero. scanf("%d", &students); // Input the number of students. if (students==0) break; // If the input number is 0, stop the loop and terminate the program. for (i=0; i=1; j--) for (k=1; k<=j; k++) { if (enrollment[i][k-1]>enrollment[i][k]) { // Swapping operation. temp = enrollment[i][k-1]; enrollment[i][k-1] = enrollment[i][k]; enrollment[i][k] = temp; } } } for (i=0; imost_popular) { // The current combination is the most popular one. most_popular = combination; // Update the most popular combination. popular_count = 1; // One combination is the most popular. } else if (combination==most_popular) // Same as the most popular combination. popular_count++; // Add one more combination to the popular count. } } printf("%d\n", most_popular * popular_count); // Output the number of students taking most-popular combinations. } return 0; }