回覆列表
  • 1 # uotkn25480

    // 節點資料結構定義struct Node{ int data; struct Node *next;};// 定位第i個節點struct Node *Locate(struct Node head, int i){ struct Node *p = &head; int k; for(k = 0; k next; } return p;}// 尋找最大值int max(struct Node head){ struct Node *p = head.next; int max = -1; if(p != NULL) { // 若第一個節點不空,則先將最大值初始化成第一個節點的值,再與後面節點的值進行比較 max = p->data; p = p->next; while(p) { max = p->data > max ? p->data : max; p = p->next; } } return max;}// 同值節點計數int number(struct Node head, int n){ struct Node *p = head.next; int count = 0; while(p) { if(p->data == n) { ++count; } p = p->next; } return count;}驗證的程式碼請自行編寫。

  • 中秋節和大豐收的關聯?
  • 網站計數器怎麼做?