Cycle calendar problems, cycle calendar

Source: Internet
Author: User

Cycle calendar problems, cycle calendar

There are n = 2 k contestants participating in the competition. A calendar meeting the following requirements must be designed:

(1) Each contestant must compete with other n-1 contestants once;

(2) Each contestant can only play once a day.

(3) Round Robin lasts for a total of N-1 days.

Design a competition calendar. The table has n rows and n-1 columns, and row I j columns are the contestants on the j day of the contestant.

# Include <stdio. h> # include <math. h> int a [100] [100]; void match (int k) {int n, temp, I, j; n = 2; // k = 0 two contestants can directly obtain a [1] [1] = 1; a [1] [2] = 2; a [2] [1] = 2; a [2] [2] = 1; for (I = 1; I <k; I ++) // iterative processing, process 2 ^ n .... 2 ^ k contestant's competition schedule {temp = n; n = n * 2; // fill in the lower left corner element for (I = temp + 1; I <= n; I ++) for (j = 1; j <= temp; j ++) a [I] [j] = a [I-temp] [j] + temp; // for (I = 1; I <= temp; I ++) // copy the elements in the lower left corner to the upper right corner for (j = temp + 1; j <= n; j ++) a [I] [j] = a [I + temp] [(j + Temp) % n]; for (I = temp + 1; I <= n; I ++) // copy the element in the upper left corner to the lower right corner for (j = temp + 1; j <= n; j ++) a [I] [j] = a [I-temp] [j-temp];} for (I = 1; I <= n; I ++) for (j = 1; j <= n; j ++) {printf ("% d ", a [I] [j]); if (j = n) printf ("\ n") ;}} int main () {int k; scanf ("% d", & k); if (k! = 0) match (k );}

 

Related Article

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.