private DataTable CountNums(List <string> lstInput) { Dictionary <string, int> dicNums = new Dictionary <string, int>(); for (int index = 1; index <= new CglDataSet(_gstuSearch.LottoType).LottoNumbers; index++) { dicNums.Add(string.Format(InvariantCulture, "{0:d2}", index), 0); } foreach (string Nums in lstInput) { if (!string.IsNullOrEmpty(Nums)) { foreach (string num in Nums.Split(',')) { if (dicNums.ContainsKey(int.Parse(num, InvariantCulture).ToString("d2", InvariantCulture))) { dicNums[int.Parse(num, InvariantCulture).ToString("d2", InvariantCulture)]++; } else { dicNums.Add(int.Parse(num, InvariantCulture).ToString("d2", InvariantCulture), 1); } } } } //dicNums = dicNums.OrderBy(x => x.Key).ToDictionary(x => x.Key, x => x.Value); Dictionary <string, int> dicNumsSort = dicNums.OrderBy(x => x.Value).ToDictionary(x => x.Key, x => x.Value); return(new CglFunc().CDicTOTable(dicNumsSort, null)); }
public DiffLine Clone() { return(new DiffLine( State, (DiffLineState[])States.Clone(), (int[])Nums.Clone(), Text, Ending)); }
public int GetEdgeIndex(int v0, int v1) { Nums.Sort(ref v0, ref v1); var ve0 = vertices[v0]; var ve1 = vertices[v1]; var ee = FindEdgeEntry(ve0, ve1); return(ee != null?edges.BinarySearch(ee) : -1); }
public Game() { Random rnd = new Random(Environment.TickCount); for (int i = 0; i != GameStatic.SizeSqr; ++i) { Nums.Add(i); } Nums = Nums.OrderBy(item => rnd.Next()).ToList(); }
public int AddEdge(int v0, int v1) { Nums.Sort(ref v0, ref v1); var ve0 = vertices[v0]; var ve1 = vertices[v1]; var newEdge = AddEdgeInternal(ve0, ve1); var lastEdgeIndex = edges.Count - 1; return(edges[lastEdgeIndex] == newEdge ? lastEdgeIndex : edges.BinarySearch(newEdge)); }
static void Main(string[] args) { Nums A = new Nums(); A.show(); Nums B = new Nums(10); B.show(); Nums C = new Nums(22, 33); C.show(); Console.ReadKey(); }
public int AddFace(int v0, int v1, int v2, int v3) { Nums.Sort(ref v0, ref v1, ref v2); if (v0 == v1 || v1 == v2 || v2 == v3) { throw new ArgumentException("A face cannot have duplicate vertices."); } var ve0 = vertices[v0]; var ve1 = vertices[v1]; var ve2 = vertices[v2]; var ve3 = vertices[v3]; foreach (var face in ve0.Faces) { if (face.Vertices.Count == 4 && face.Vertices[1] == ve1 && face.Vertices[2] == ve2 && face.Vertices[3] == ve3) { return(faces.BinarySearch(face)); } } var newFace = FacePool.Get(); newFace.Vertices.Add(ve0); newFace.Vertices.Add(ve1); newFace.Vertices.Add(ve2); newFace.Vertices.Add(ve3); ve0.Faces.Add(newFace); ve1.Faces.Add(newFace); ve2.Faces.Add(newFace); ve3.Faces.Add(newFace); var ee0 = AddEdgeInternal(ve0, ve1); var ee1 = AddEdgeInternal(ve1, ve2); var ee2 = AddEdgeInternal(ve2, ve3); var ee3 = AddEdgeInternal(ve0, ve3); newFace.Edges.Add(ee0); newFace.Edges.Add(ee1); newFace.Edges.Add(ee2); newFace.Edges.Add(ee3); ee0.Faces.Add(newFace); ee1.Faces.Add(newFace); ee2.Faces.Add(newFace); ee3.Faces.Add(newFace); faces.Add(newFace); return(faces.Count - 1); }
// Parsowanie liczb z TextBoxa. public void ParseInputNums(string input) { string[] strs = input.Split(' '); if (strs.Length >= 0) { List <int> arguments = new List <int>(); for (int i = 0; i < strs.Length; i++) { this.Nums.Add(int.Parse(strs[i])); } this.NumsLength = Nums.Count(); } }
public MainViewModel() { Nums.Add(new Model(1)); Nums.Add(new Model(0)); Nums.Add(new Model(1)); Nums.Add(new Model(1)); Nums.Add(new Model(0)); CollectionViewZero = new CollectionViewSource { Source = Nums }.View; CollectionViewZero.Filter = ReturnZeroFilter; CollectionViewOne = new CollectionViewSource { Source = Nums }.View; CollectionViewOne.Filter = ReturnOneFilter; }
static void Main(string[] args) { Nums A = new Nums(); A.show(); A.set(25); A.show(); A.set(); A.show(); A.set(12258); A.show(); Nums B = new Nums(1225); B.show(); Nums C = new Nums(27); C.show(); Console.ReadKey(); }
public int GetFaceIndex(int v0, int v1, int v2) { Nums.Sort(ref v0, ref v1, ref v2); if (v0 == v1 || v1 == v2) { throw new ArgumentException("A face cannot have duplicate vertices."); } var ve0 = vertices[v0]; var ve1 = vertices[v1]; var ve2 = vertices[v2]; foreach (var face in ve0.Faces) { if (face.Vertices.Count == 3 && face.Vertices[1] == ve1 && face.Vertices[2] == ve2) { return(faces.BinarySearch(face)); } } return(-1); }
public MainPage(Tournament tournament) { WaitWindow waitWindow = new WaitWindow(); waitWindow.Show(); InitializeComponent(); CurrentTournament = tournament; Nums = new Nums(); Context = new BadmintonContext(); ListPage = new ListPage(this); changerFrame.Navigate(ListPage); #region LoadContext Context.Cities.Load(); Context.Grades.Load(); Context.Clubs.Load(); Context.Coaches.Load(); Context.Unions.Load(); Context.TeamsTournaments.Load(); Context.PlayersTeams.Load(); #endregion TornamentPlayersHelper = new TornamentPlayersHelper(Context, CurrentTournament); EventsHelper = new EventsHelper(Context, CurrentTournament); PlayersHelper = new PlayersHelper(Context); Context.Configuration.AutoDetectChangesEnabled = true; EventsHelper.EventsLoad(); PlayersHelper.PlayersLoad(); TornamentPlayersHelper.TeamTournamentsLoad(); eventsListBox.ItemsSource = EventsHelper.EventsList; DrawsPage = new DrawsPage(this); if (eventsListBox.Items.Count > 0) { eventsListBox.SelectedIndex = 0; } waitWindow.Close(); }
public void FindBaseLine() { if (pointsList.Count < 2) { throw new Exception("Точек меньше двух"); } int indexStartPoint = 0; for (int i = 0; i < pointsList.Count; i++) { if (pointsList[i].X < pointsList[indexStartPoint].X) { indexStartPoint = i; } } int indexNextPoint = indexStartPoint == 0 ? 1 : 0; for (int i = 0; i < pointsList.Count; i++) { if ((indexStartPoint != indexNextPoint) && (Rotate(pointsList[indexStartPoint], pointsList[indexNextPoint], pointsList[i]) > 0)) { indexNextPoint = i; } } if (indexNextPoint == indexStartPoint) { throw new Exception("Ошибка алгоритма"); } Pen blackPen = new Pen(Color.Green, 1); using (var graphics = Graphics.FromImage(bmp)) { graphics.DrawLine(blackPen, pointsList[indexStartPoint].X, pointsList[indexStartPoint].Y, pointsList[indexNextPoint].X, pointsList[indexNextPoint].Y); } //нужные области для базовой линии int areaNumber1 = -1, areaNumber2 = -1; for (int i = 0; i < areasList.Count; i++) { if (areasList[i].rect.Contains(pointsList[indexStartPoint])) { areaNumber1 = i; } if (areasList[i].rect.Contains(pointsList[indexNextPoint])) { areaNumber2 = i; } } Nums numms1 = new Nums(-1, -1, -1, -1, -1); numms1.searchForNeighbors(3, areaNumber1); Nums numms2 = new Nums(-1, -1, -1, -1, -1); numms2.searchForNeighbors(3, areaNumber2); //для линии соседи List <Nums> numslist = new List <Nums>(); numslist.Clear(); for (int i = 0; i < areasList.Count; i++) { int one = 0, two = 0, three = 0, four = 0; for (int j = 0; j < areasList[i].vertices.Count; j++) { if (j == 0) { one = Rotate(pointsList[indexStartPoint], pointsList[indexNextPoint], verticesList[j]); } if (j == 1) { two = Rotate(pointsList[indexStartPoint], pointsList[indexNextPoint], verticesList[j]); } if (j == 2) { three = Rotate(pointsList[indexStartPoint], pointsList[indexNextPoint], verticesList[j]); } if (j == 3) { four = Rotate(pointsList[indexStartPoint], pointsList[indexNextPoint], verticesList[j]); } } if (one < 0 && two < 0 && three > 0 && four > 0) { int area1 = i; Nums numms3 = new Nums(-1, -1, -1, -1, -1); numms3.searchForNeighbors(3, area1); numslist.Add(numms3); } if (two < 0 && three < 0 && one > 0 && four > 0) { int area = i; Nums numms4 = new Nums(-1, -1, -1, -1, -1); numms4.searchForNeighbors(3, area); numslist.Add(numms4); } if (three < 0 && four < 0 && one > 0 && two > 0) { int area = i; Nums numms5 = new Nums(-1, -1, -1, -1, -1); numms5.searchForNeighbors(3, area); numslist.Add(numms5); } if (one < 0 && four < 0 && two > 0 && three > 0) { int area = i; Nums numms6 = new Nums(-1, -1, -1, -1, -1); numms6.searchForNeighbors(3, area); numslist.Add(numms6); } if (one < 0 && three < 0 && two > 0 && four > 0) { int area = i; Nums numms7 = new Nums(-1, -1, -1, -1, -1); numms7.searchForNeighbors(3, area); numslist.Add(numms7); } if (two < 0 && four < 0 && one > 0 && three > 0) { int area = i; Nums numms8 = new Nums(-1, -1, -1, -1, -1); numms8.searchForNeighbors(3, area); numslist.Add(numms8); } } }
public void DerivedTeardown() { Nums.Add(5); Assert.AreEqual(new List<int> { 0, 1, 2, 3, 4, 5 }, Nums); }
public override EdgarDatasetPresentation Parse(IAnalystEdgarDatasetsRepository repository, List <string> fieldNames, List <string> fields, int lineNumber) { /* * adsh report line stmt inpth rfile tag version prole plabel negating * 0001163302-16-000148 1 4 CP 0 H DocumentFiscalYearFocus dei/2014 terseLabel Document Fiscal Year Focus 0 * 0001163302-16-000148 1 3 CP 0 H DocumentPeriodEndDate dei/2014 terseLabel Document Period End Date 0 * 0001125345-17-000041 6 1 CF 0 H NetCashProvidedByUsedInOperatingActivitiesContinuingOperationsAbstract us-gaap/2015 terseLabel Operating activities 0 * 0001104659-17-016575 111 6 0 H NetCashProvidedByUsedInOperatingActivitiesContinuingOperationsAbstract us-gaap/2015 terseLabel Cash flows from operating activities: 0 * ... */ try { EdgarDatasetPresentation pre; string adsh = fields[fieldNames.IndexOf("adsh")]; string line = fields[fieldNames.IndexOf("line")]; string report = fields[fieldNames.IndexOf("report")]; //select S.ADSH + CAST(p.ReportNumber as varchar) + cast(p.Line as varchar) [key] ... //string key = adsh + report + line; pre = new EdgarDatasetPresentation(); pre.SubmissionId = Subs[adsh]; pre.ReportNumber = Convert.ToInt32(report); pre.RenderId = Renders[adsh + report]; pre.Line = Convert.ToInt32(line); pre.FinancialStatement = fields[fieldNames.IndexOf("stmt")]; pre.Inpth = fields[fieldNames.IndexOf("inpth")] == "1"; int index = fieldNames.IndexOf("rfile"); if (index >= 0) { pre.RenderFile = fields[fieldNames.IndexOf("rfile")][0]; pre.RenderFileStr = fields[fieldNames.IndexOf("rfile")]; } else { pre.RenderFileStr = null; pre.RenderFile = char.MinValue; } string tag = fields[fieldNames.IndexOf("tag")]; string version = fields[fieldNames.IndexOf("version")]; if (Tags.ContainsKey(tag + version)) { pre.TagId = Tags[tag + version]; } else { string tag2 = Encoding.GetEncoding(1252).GetString(Encoding.GetEncoding("iso-8859-7").GetBytes(tag)); if (Tags.ContainsKey(tag + version)) { pre.TagId = Tags[tag + version]; } else { throw new EdgarLineException(EdgarDatasetPresentation.FILE_NAME, lineNumber, "Error retrieving key: " + tag + version); } } pre.PreferredLabelXBRLLinkRole = fields[fieldNames.IndexOf("prole")]; pre.PreferredLabel = fields[fieldNames.IndexOf("plabel")]; pre.Negating = !(fields[fieldNames.IndexOf("negating")] == "0"); pre.LineNumber = lineNumber; string numKey = adsh + tag + version; if (Nums.ContainsKey(numKey)) { pre.NumberId = Nums[numKey]; } else { pre.ADSH_Tag_Version = adsh + "|" + tag + "|" + version; } if (Texts.ContainsKey(numKey)) { pre.TextId = Texts[numKey]; } else { pre.ADSH_Tag_Version = adsh + "|" + tag + "|" + version; } return(pre); } catch (Exception ex) { throw ex; } }
public override void Parse(List <string> fieldNames, List <string> fields, int lineNumber, DataRow dr, int edgarDatasetId) { /* * adsh report line stmt inpth rfile tag version prole plabel negating * 0001163302-16-000148 1 4 CP 0 H DocumentFiscalYearFocus dei/2014 terseLabel Document Fiscal Year Focus 0 * 0001163302-16-000148 1 3 CP 0 H DocumentPeriodEndDate dei/2014 terseLabel Document Period End Date 0 * 0001125345-17-000041 6 1 CF 0 H NetCashProvidedByUsedInOperatingActivitiesContinuingOperationsAbstract us-gaap/2015 terseLabel Operating activities 0 * 0001104659-17-016575 111 6 0 H NetCashProvidedByUsedInOperatingActivitiesContinuingOperationsAbstract us-gaap/2015 terseLabel Cash flows from operating activities: 0 * ... */ try { string adsh = fields[fieldNames.IndexOf("adsh")]; string line = fields[fieldNames.IndexOf("line")]; string report = fields[fieldNames.IndexOf("report")]; dr["SubmissionId"] = Subs[adsh]; dr["ReportNumber"] = Convert.ToInt32(report); dr["RenderId"] = Renders[adsh + report]; dr["Line"] = Convert.ToInt32(line); dr["FinancialStatement"] = fields[fieldNames.IndexOf("stmt")]; dr["Inpth"] = fields[fieldNames.IndexOf("inpth")] == "1"; int index = fieldNames.IndexOf("rfile"); if (index >= 0) { dr["RenderFileStr"] = fields[index][0]; } else { dr["RenderFileStr"] = DBNull.Value; } string tag = fields[fieldNames.IndexOf("tag")]; string version = fields[fieldNames.IndexOf("version")]; if (Tags.ContainsKey(tag + version)) { dr["TagId"] = Tags[tag + version]; } else { string tag2 = Encoding.GetEncoding(1252).GetString(Encoding.GetEncoding("iso-8859-7").GetBytes(tag)); if (Tags.ContainsKey(tag + version)) { dr["TagId"] = Tags[tag + version]; } else { throw new EdgarLineException(EdgarDatasetPresentation.FILE_NAME, lineNumber, "Error retrieving key: " + tag + version); } } dr["PreferredLabelXBRLLinkRole"] = fields[fieldNames.IndexOf("prole")]; dr["PreferredLabel"] = fields[fieldNames.IndexOf("plabel")]; dr["Negating"] = !(fields[fieldNames.IndexOf("negating")] == "0"); dr["DatasetId"] = edgarDatasetId; dr["LineNumber"] = lineNumber; string numKey = adsh + tag + version; if (Nums.ContainsKey(numKey)) { dr["NumberId"] = Nums[numKey]; } else { dr["ADSH_Tag_Version"] = adsh + " | " + tag + "|" + version; } if (Texts.ContainsKey(numKey)) { dr["TextId"] = Texts[numKey]; } else { dr["ADSH_Tag_Version"] = adsh + " | " + tag + "|" + version; } } catch (Exception ex) { throw ex; } }
public void DerivedSetup() { Nums.Add(2); }
private void Awake() { nums = GetComponentInParent <Nums>(); AwakeChild(); }
public static void Main() { int[] input = Console.ReadLine().Split(new[] { ' ', ',', '\t', '\n' }, StringSplitOptions.RemoveEmptyEntries) .Select(int.Parse).ToArray(); List <Nums> nums = new List <Nums>(); for (int i = 0; i < input.Length; i++) { var currentNum = string.Empty; Nums current = new Nums(); for (int j = 0; j < input[i].ToString().Length; j++) { switch (input[i].ToString()[j]) { case '1': currentNum += "one"; break; case '2': currentNum += "two"; break; case '3': currentNum += "three"; break; case '4': currentNum += "four"; break; case '5': currentNum += "five"; break; case '6': currentNum += "six"; break; case '7': currentNum += "seven"; break; case '8': currentNum += "eight"; break; case '9': currentNum += "nine"; break; case '0': currentNum += "zero"; break; } if (input[i].ToString().Length > j) { currentNum += "-"; } } current.Number = input[i]; current.WritenNumber = currentNum; nums.Add(current); } var newList = nums.OrderBy(x => x.WritenNumber).Select(x => x.Number).ToList(); Console.Write(string.Join(", ", newList)); }
public void SubDerivedSetup() { Nums.Add(3); }