static void Main() { //input int arraySize = int.Parse(Console.ReadLine()); int numbK = int.Parse(Console.ReadLine()); // get the array numbK 3 int int[] arrayA = new int[arraySize]; for (int i = 0; i < arraySize; i++) { arrayA[i] = int.Parse(Console.ReadLine()); } myCompare comp = new myCompare(); //sort the array Array.Sort(arrayA, comp); // get the sum int maxSum = 0; for (int i = 0; i < numbK; i++) { maxSum += arrayA[arrayA.Length - 1 - i]; } //print Console.WriteLine(maxSum); }
static void Main() { //input int arraySize = int.Parse(Console.ReadLine()); int numbK = int.Parse(Console.ReadLine()); // get the array numbK 3 int int[] arrayA = new int[arraySize]; for (int i = 0; i < arraySize; i++) { arrayA[i] = int.Parse(Console.ReadLine()); } myCompare comp = new myCompare(); //sort the array Array.Sort(arrayA, comp); // get the sum int maxSum = 0; for (int i = 0; i < numbK; i++) { maxSum += arrayA[arrayA.Length - 1 - i]; } //print Console.WriteLine(maxSum); }
static void Main() { // input int arraySize = int.Parse(Console.ReadLine()); // get array string[] toSearch = new string[arraySize]; for (int i = 0; i < arraySize; i++) { toSearch[i] = Console.ReadLine(); } // initialize custom sort myCompare sortStrLength = new myCompare(); // sort Array.Sort(toSearch, sortStrLength); // print the results Console.WriteLine(string.Join(Environment.NewLine, toSearch)); }
static void Main() { // input int arraySize = int.Parse(Console.ReadLine()); // get array string[] toSearch = new string[arraySize]; for (int i = 0; i < arraySize; i++) { toSearch[i] = Console.ReadLine(); } // initialize custom sort myCompare sortStrLength = new myCompare(); // sort Array.Sort(toSearch, sortStrLength); // print the results Console.WriteLine(string.Join(Environment.NewLine, toSearch)); }
public Hashtable HashValSort(DataTable ht) { ArrayList list = ht.GetValues(); myCompare Compare = new myCompare(); list.Sort(Compare); Hashtable hb = new Hashtable(); foreach (Scene_CitySceneTableItem svalue in list) { IDictionaryEnumerator ide = ht.GetEnumerator(); while (ide.MoveNext()) { if (ide.Value == svalue) { hb.Add(ide.Key, svalue); } } } return(hb); }
private void presentResult(int battleType) { //使用率分布 KeyValuePair <string, double>[] ur = az.useageRateTop(200); //列表 listView4.Items.Clear(); for (int i = 0; i < ur.Length; i++) { ListViewItem lvi = new ListViewItem(); lvi.Text = (i + 1).ToString(); lvi.SubItems.Add(ur[i].Key); double y; if (battleType == 1) { y = ur[i].Value * 300; } else if (battleType == 2 || battleType == 4) { y = ur[i].Value * 400; } else if (battleType == 3) { y = ur[i].Value * 600; } else { y = ur[i].Value * 100 * ((int)GlobalConstants.GENESPECIALPARA[int.Parse(GlobalConstants.DEFAULTGENERATION)]); } lvi.SubItems.Add(Math.Round(y, 2) + "%"); listView4.Items.Add(lvi); } //折线图 chart2.Series.Clear(); chart2.ChartAreas[0].AxisX.Minimum = 1; chart2.ChartAreas[0].AxisY.Minimum = 0; chart2.ChartAreas[0].AxisY.Maximum = 80; Series series = new Series("StackedArea"); series.ChartType = SeriesChartType.Line; series.BorderWidth = 2; series.ShadowOffset = 0; int limitation = Math.Min(50, ur.Length); for (int i = 0; i < limitation; i++) { double y; if (battleType == 1) { y = ur[i].Value * 300; } else if (battleType == 2 || battleType == 4) { y = ur[i].Value * 400; } else if (battleType == 3) { y = ur[i].Value * 600; } else { y = ur[i].Value * 100 * ((int)GlobalConstants.GENESPECIALPARA[int.Parse(GlobalConstants.DEFAULTGENERATION)]); } series.Points.AddXY(i + 1, y); } chart2.Series.Add(series); //速度修正分布 extSpeedPoints = az.speedDistribution(); listView1.Items.Clear(); foreach (KeyValuePair <int, double> point in extSpeedPoints) { ListViewItem lvi = new ListViewItem(); lvi.SubItems.Add(point.Key.ToString()); lvi.SubItems.Add(Math.Round(point.Value, 1) + "%"); if (point.Value >= GlobalConstants.EXTREMESPEEDRATEVERYHIGH) { lvi.BackColor = Color.DeepSkyBlue; } else if (point.Value >= GlobalConstants.EXTREMESPEEDRATEHIGH) { lvi.BackColor = Color.LightSkyBlue; } else if (point.Value >= GlobalConstants.EXTREMESPEEDRATELOW) { lvi.BackColor = Color.LightPink; } else { lvi.BackColor = Color.Red; } listView1.Items.Add(lvi); } //速度种族分布 racialSpeedPoints = az.speedRacialDistribution(); listView5.Items.Clear(); foreach (KeyValuePair <int, int> point in racialSpeedPoints) { ListViewItem lvi = new ListViewItem(); lvi.SubItems.Add(point.Key.ToString()); lvi.SubItems.Add(point.Value.ToString()); listView5.Items.Add(lvi); } //速度种族权重分布 racialSpeedWeightedPoints = az.speedRacialWeightedDistribution(); listView6.Items.Clear(); foreach (KeyValuePair <int, double> point in racialSpeedWeightedPoints) { ListViewItem lvi = new ListViewItem(); lvi.SubItems.Add(point.Key.ToString()); lvi.SubItems.Add(Math.Round(point.Value, 1).ToString()); listView6.Items.Add(lvi); } //速度种族权重累加分布 racialSpeedWeightedAccumulatedPoints = az.speedRacialWeightedAccumulatedDistribution(racialSpeedWeightedPoints); listView7.Items.Clear(); foreach (KeyValuePair <int, double> point in racialSpeedWeightedAccumulatedPoints) { ListViewItem lvi = new ListViewItem(); lvi.SubItems.Add(point.Key.ToString()); lvi.SubItems.Add(Math.Round(point.Value, 2).ToString() + "%"); listView7.Items.Add(lvi); } //技能列表 listView2.Items.Clear(); ArrayList moves = az.moveDistribution(); int rank = 1; foreach (KeyValuePair <string, double> move in moves) { ListViewItem lvi = new ListViewItem(); string[] moveDetail = move.Key.Split(','); lvi.Text = rank.ToString(); lvi.SubItems.Add(moveDetail[0]); lvi.SubItems.Add(Math.Round(move.Value, 1) + "%"); lvi.BackColor = GlobalConstants.TYPECOLORS[int.Parse(moveDetail[1]) - 1]; lvi.ForeColor = Color.White; listView2.Items.Add(lvi); rank++; } //mega配比列表 rank = 1; ArrayList megaDetails = az.megaUsageRate(ah); myCompare mc = new myCompare(); megaDetails.Sort(mc); listView3.Items.Clear(); double total = ((KeyValuePair <string, double>)(megaDetails[0])).Value; double single; if (battleType == 1) { single = total * 3 / 100; } else if (battleType == 2 || battleType == 4) { single = total * 4 / 100; } else if (battleType == 3) { single = total * 6 / 100; } else { single = total * ((int)GlobalConstants.GENESPECIALPARA[int.Parse(GlobalConstants.DEFAULTGENERATION)]) / 100; } label9.Text = Math.Round(single, 2) + "只"; for (int i = 1; i < megaDetails.Count; i++) { KeyValuePair <string, double> megaPoke = (KeyValuePair <string, double>)megaDetails[i]; ListViewItem lvi = new ListViewItem(); lvi.Text = rank.ToString(); lvi.SubItems.Add(megaPoke.Key.Replace("Mega", "")); lvi.SubItems.Add(Math.Round(megaPoke.Value * 100 / total, 2) + "%"); listView3.Items.Add(lvi); rank++; } //神兽统计 label11.Text = Math.Round(az.ancientUsageRate() * ((int)GlobalConstants.GENESPECIALPARA[int.Parse(GlobalConstants.DEFAULTGENERATION)]), 2) + "只"; }