ערכתי לאחרונה בתאריך 30.10.07 בשעה 15:58 בברכה, ronen333
המורה שלי התחילה ללמד אותנו היום על חוליות באוספים.
לא כל כך הצלחתי להתרכז כי היה כמה תמידים שחפרו לי מאחור שהם יפנצרו לי את האופניים, אבל זה בסדר בסוף שיעור הכנסתי להם אגרוף לפנים והם הלכו.ANYWAY, הבקשה היתה כזאת: "כתוב פעולה לקליטת נתונים שלמים וחיובים לשרשרת חוליות הפעולה תבנה שרשרת חדשה ותחזיר הפניה לתחילת השרשרת. תהליך הקליטה יעצר כאשר יוקש מס' שלילי".
אין לי מושג איך לעשות את זה ואני שמח מאוד לקצת עזרה לפני יום חמישי.
מחלקות:
using System; using System.Collections.Generic; using System.Text;namespace Chain { class Program { public static IntNode Klita() //כאן אני אמור להמשיך את שעורי הבית { } public static void PrintChain(IntNode pos) //מדפיס את החוליות { while (pos != null) { Console.WriteLine(pos); pos = pos.GetNext(); } } static void Main(string args) { IntNode n = new IntNode(1); IntNode n1 = new IntNode(2,n); IntNode n2 = new IntNode(3, n1); } } }
|
using System; using System.Collections.Generic; using System.Text;namespace Chain { class IntNode { private int info; private IntNode next; public IntNode(int info) { this.info = info; this.next = null; } public IntNode(int info, IntNode next) { this.info = info; this.next = next; } public IntNode GetNext() { return this.next; } public int GetInfo() { return this.info; } public void SetNext(IntNode next) { this.next = next; } public void SetInfo(int info) { this.info = info; } public override string ToString() { return " "+this.info; } } }
|
תודה רבה מראש לכל אחד שיעזור ;)

