Esempio n. 1
0
 static void Main(string[] args)
 {
     Console.WriteLine("Start");
     StreamReader sr = new StreamReader("laba9.txt");
     string line;
     line = sr.ReadLine();
     maxvesvezhi = int.Parse(line);
     line = sr.ReadLine();
     maxVolume = int.Parse(line);
     Console.WriteLine("Max vesvezhi: " + maxvesvezhi);
     Console.WriteLine("Max volume: " + maxVolume);
     while (true)
     {
         line = sr.ReadLine();
         if (line == null)
             break;
         string[] spl = line.Split(new char[] { ',' });
         Unit u = new Unit();
         u.ispolz = 0;
         u.stoimost = int.Parse(spl[0]);
         u.volume = int.Parse(spl[1]);
         u.vesvezhi = int.Parse(spl[2]);
         sklad.Add(u);
     }
     search();
     Console.WriteLine("Results:");
     int curV = 0;
     int curW = 0;
     for (IEnumerator e = max.GetEnumerator(); e.MoveNext(); )
     {
         Console.WriteLine(((Unit) e.Current).stoimost + " : " +
             ((Unit) e.Current).vesvezhi + " : " +
             ((Unit) e.Current).volume);
         curV += ((Unit) e.Current).volume;
         curW += ((Unit) e.Current).vesvezhi;
     }
     Console.WriteLine("Total:");
     Console.WriteLine("  stoimost: "+maxSt);
     Console.WriteLine("  vesvezhi: " + curW);
     Console.WriteLine("  Volume: " + curV);
     Console.ReadLine();
 }
Esempio n. 2
0
 static void Main(string[] args)
 {
     System.IO.StreamReader sr = new System.IO.StreamReader("D:/tmp/laba8.txt");
     string line;
     line = sr.ReadLine();
     maxWeight = int.Parse(line);
     line = sr.ReadLine();
     maxVolume = int.Parse(line);
     Console.WriteLine("Max weight: " + maxWeight);
     Console.WriteLine("Max volume: " + maxVolume);
     while (!sr.EndOfStream)
     {
         line = sr.ReadLine();
         string[] spl = line.Split(new char[] { ',' });
         Unit u = new Unit();
         u.inuse = 0;
         u.usefullness = int.Parse(spl[0]);
         u.volume = int.Parse(spl[1]);
         u.weight = int.Parse(spl[2]);
         store.AddLast(u);
     }
     search();
     Console.WriteLine("Results:");
     int curV = 0;
     int curW = 0;
     for (IEnumerator<Unit> e = max.GetEnumerator(); e.MoveNext(); )
     {
         Console.WriteLine(e.Current.usefullness + " : " +
             e.Current.weight + " : " +
             e.Current.volume);
         curV += e.Current.volume;
         curW += e.Current.weight;
     }
     Console.WriteLine("Total:");
     Console.WriteLine("  Usefullness: "+maxUFNess);
     Console.WriteLine("  Weight: " + curW);
     Console.WriteLine("  Volume: " + curV);
     Console.ReadLine();
 }
Esempio n. 3
0
 public Unit(Unit u)
 {
     this.vesvezhi = u.vesvezhi;
     this.stoimost = u.stoimost;
     this.ispolz = u.ispolz;
     this.volume = u.volume;
 }
Esempio n. 4
0
 public Unit(Unit u)
 {
     this.weight = u.weight;
     this.usefullness = u.usefullness;
     this.inuse = u.inuse;
     this.volume = u.volume;
 }