拉丁方陣 單迴圈鍊錶實現

2021-07-10 10:48:10 字數 670 閱讀 1029

#include#includetypedef struct nodenode,*linklist;

void create******cyclelist_tail(linklist *l,int number)

(*l)->next = *l; //初始化了鍊錶

for(count = 1; count <= number; count++ )

new->data = count;

new->next = (*l)->next;

(*l)->next = new;

*l = new;

} //建立了單迴圈鍊錶,有頭結點

temp = (*l)->next;

(*l)->next = temp->next;

*l = temp->next;

free(temp); //將頭結點刪除

}void showlatinsquare(linklist l,int number)

printf("\n");

l = l->next; //輸出完一行後,l要後移兩個位置

//但是48行**已經移動乙個,在這

//後移乙個即可。

count_out++; }}

int main()

利用迴圈鍊錶列印拉丁方陣

拉丁方陣就是乙個n n 2 n 9 的方陣,每個格仔裡存放乙個數字,要求每一橫行每一縱行數字不重複。例如 1 22 1 n要求由使用者輸入 c語言實現 include include typedef struct ldla la newlist int void print la int intma...

單迴圈鍊錶

頭插 尾插 顯示 頭刪 尾刪 按值插入 按位置插入 查詢 長度 逆序 清除 摧毀 初始化 排序 按位置刪除 按值刪除 可以進一步優化 ifndef sclist h define sclist h include typedef int elementtype typedef enum bool 鍊...

單迴圈鍊錶

乙個遊戲,數到第n人出列 include include include struct people struct people creat struct people head,int n else p struct people malloc sizeof struct people tail ...