Advertisement
AvengersAssemble

Q3

Mar 15th, 2015
264
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.84 KB | None | 0 0
  1. Main.cs
  2.  
  3. using System;
  4. using Unit4.CollectionsLib;
  5. using System.Linq;
  6. using System.Text;
  7.  
  8. namespace רונית_תמותי
  9. {
  10.     class Program
  11.     {
  12.  
  13.         public static Node<SubList> MakeSubList(Node<int> n)
  14.         {
  15.             Node<SubList> tempSub;
  16.             Node<SubList> subL = new Node<SubList>(new SubList(0, n, 0));
  17.             Node<int> tmp = n;
  18.             int sum, count;
  19.             while (tmp != null)
  20.             {
  21.                 sum = count = 0;
  22.                 while (tmp.GetInfo() != 0)
  23.                 {
  24.                     count++;
  25.                     sub += tmp.GetInfo();
  26.                     tmp = tmp.GetNext();
  27.                 }
  28.                 subL.GetInfo().Sum = sum;
  29.                 subL.GetInfo().Count = count;
  30.                 tempSub = new Node<SubList>(new SubList(0, tmp, 0));
  31.                 tempSub.SetNext(subL);
  32.                 subL = tempSub;
  33.             }
  34.             return subL;
  35.  
  36.         }
  37.         static void Main(string[] args)
  38.         {
  39.  
  40.         }
  41.     }
  42. }
  43.  
  44.  
  45. *******
  46.  
  47.  
  48. SubList.cs
  49.  
  50. using System;
  51. using Unit4.CollectionsLib;
  52. using System.Linq;
  53. using System.Text;
  54.  
  55. namespace רונית_תמותי
  56. {
  57.     public class SubList
  58.     {
  59.         private Node<int> p;
  60.         private int count;
  61.         private int sum;
  62.  
  63.         public SubList(int count, Node<int> p, int sum)
  64.         {
  65.             this.count = count;
  66.             this.p = p;
  67.             this.sum = sum;
  68.         }
  69.  
  70.         public int Count
  71.         {
  72.             get { return this.count; }
  73.             set { this.count = value; }
  74.         }
  75.  
  76.         public Node<int> Pointer
  77.         {
  78.             get { return this.p; }
  79.             set { this.p = value; }
  80.         }
  81.  
  82.         public int Sum
  83.         {
  84.             get { return this.sum; }
  85.             set { this.sum = value; }
  86.         }
  87.     }
  88. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement