30/09/2018, 16:54

Phân số Farey tổ chức theo linkedlist

Bài toán này phải tổ chức theo linkedlist như thế nào vậy ạ ?

Farey fractions of level one are defined as sequence (0/1;1/1). This sequence is extended in level two to form a sequence (0/1;1/2;1/1), sequence (0/1;1/3;1/2;2/3;1/1) at level three, sequence (0/1;1/4;1/3;1/2;2/3;3/4;1/1) at level four, so that each level n, a new fraction (a+c)/(b+d) is inserted between two neighbor fractions a/c and b/d only if c+d<=n. Write a program that for a number n entered by the user creates-by constantly extending it-a linked list of fractions at level n and the n displays them.

Bài liên quan
0