Et nyt nationalt initiativ fra Industriens Fond, EIFO og Innovationsfonden – eksekveret af DTU Science Park og Teknologisk Institut– skal bygge bro mellem startups, SMV’er og Forsvaret.
Jeg kan godt læse det ind hvis det kun er koordinaterne men ikke demand endvidere så er problemet hvor jeg håndtere teksten , ville gerne undgå at skulle rette alle test filerne. hvis muligt.
public class knuder {
List<int> x_coord = null; List<int> y_coord = null; public int KAntal;
public void read_coordinates(string filename) { TextReader tr = new StreamReader(filename);
// Læser textfilen ind i en min liste List<string> input = new List<string>();
class Program { public class Foo { public int X { get; private set; } public int Y { get; private set; } public int Demand { get; set; }
public Foo(int x, int y) { X = x; Y = y; }
public override string ToString() { return string.Format("X: {0}, Y: {1}, Demand: {2}", X, Y, Demand); } }
static void Main(string[] args) { var dictionary = new Dictionary<string, Foo>();
var allLines = File.ReadAllLines(@"C:\test.vrp.txt", Encoding.Default);
foreach (var line in allLines.Skip(7)) { var strings = line.Trim().Split(new[] {' '}, StringSplitOptions.RemoveEmptyEntries); if(strings.Length == 3) { var key = strings[0]; var x = int.Parse(strings[1]); var y = int.Parse(strings[2]);
dictionary.Add(key, new Foo(x, y)); } else if(strings.Length == 2) { var key = strings[0];
if(!dictionary.ContainsKey(key)) throw new Exception(string.Format("Cannot find the key: '{0}' in the dictionary. This should never happen", key));
Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.