?
快捷搜索:  as  test  1111  test aNd 8=8  test++aNd+8=8  as++aNd+8=8  as aNd 8=8

金沙貴賓會0029路線:單鏈表實現Farey序列

?

The Farey sequences of orders 1 to 8 are :

F1 = {0⁄1, 1⁄1}

F2 = {0⁄1, 1⁄2, 1⁄1}

F3 = {0⁄1, 1⁄3, 1⁄2, 2⁄3, 1⁄1}

F4 = {0⁄1, 1⁄4, 1⁄3, 1⁄2, 2⁄3, 金沙貴賓會0029路線3⁄4, 1⁄1}

F5 = {0⁄1, 1⁄5, 1⁄4, 1⁄3, 2⁄5, 1⁄2, 3⁄5, 2⁄3, 3⁄4, 4⁄5, 1⁄1}

F6 = {0⁄1, 1⁄6, 1⁄5, 1⁄4, 1⁄3, 2⁄5, 1⁄2, 3⁄5, 2⁄3, 3⁄4, 4⁄5, 5⁄6, 1⁄1}

F7 = {0⁄1, 1⁄7, 1⁄6, 1&fr金沙貴賓會0029路線asl;5, 1⁄4, 2⁄7, 1⁄3, 2⁄5, 3⁄7, 1⁄2, 4⁄7, 3⁄5, 2⁄3, 5⁄7, 3⁄4, 4⁄5, 5⁄6, 6⁄7, 1⁄1}

F8 = {0⁄1, 1⁄8, 1⁄7, 1⁄6, 1⁄5,金沙貴賓會0029路線 1⁄4, 2⁄7, 1⁄3, 3⁄8, 2⁄5, 3⁄7, 1⁄2, 4⁄7, 3⁄5, 5⁄8, 2⁄3, 5⁄7, 3⁄4, 4⁄5, 5⁄6, 6⁄7, 7⁄8, 1⁄1}

在第n級上,僅當c+dpublic class Node {

private int u金沙貴賓會0029路線pval;//分子

private int dnval;//分母

private Node next;

public Node(int up, int down) {

upval = up;

dnval = down;

next = null;

}

public Node(int up, int down, Node next) {

upval = up;

dnval = down;

this.next = next;

}

public int getUpval() {

return upval;

}

public void setUpval(int upval) {

this.upval = upval;

}

public int getDnval() {

return dnval;

}

public void setDnval(int dnval) {

this.dnval = dnval;

}

public Node getNext() {

return next;

}

public void setNext(Node next) {

this.next = next;

}

}

下面是Farey序列的詳細實現

1.構造子先設定了兩個節點,即n=1的環境;

2.generate(int n)用于天生序列,每次會遍歷當前序列,假如具備插入的點,則插入之金沙貴賓會0029路線,且將added設置為真;

3.假如遍歷完后布爾值added為假,則闡明序列已構造完成;

4.整型數turn表示每次必要判斷插入的次數,它和前一輪獲得的鏈表長度有關;

public class FareyList {

private Node head;

private int size;

public FareyList() {

head = new Node(0, 1);

Node next = new Node(1, 1);

head.setNext(next);

size = 2;

}

public void insertAfter(Node newNode, Node prev) {

newNode.setNext(prev.getNext());

prev.setNext(newNode);

size++;

}

public void generate(int n) {

if (n

本文出自 “子 孑” 博客,請務必保留此出處http://zhangjunhd.blog.51cto.com/113473/54836

免責聲明:以上內容源自網絡,版權歸原作者所有,如有侵犯您的原創版權請告知,我們將盡快刪除相關內容。

您可能還會對下面的文章感興趣:

浙江体彩20选5开奖号 给我下载一个qq麻将 黄金配资 贵州茅台股票行情 互联网金融理财平台 北京麻将带混的怎么打 辽宁快乐12选5遗 河北快三开奖基本走势 四人麻将游戏单机版下载 十分快乐开奖结果 新疆11选5走势图 东方六十一最新开奖 2014世界杯冠军 中超排行榜 基金配资申请 顺市配资 血流麻将怎么打赢的多