110,499
社区成员
发帖
与我相关
我的任务
分享
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace NumMax
{
class Program
{
static void Main(string[] args)
{
float[] arrFirst = { 3, 2, 6, 4, 1, 9 };
float[] arrSecond = { 7, 14, 7, 12, 5, 22 };
float[] arrThird = new float[arrFirst.Length];
float[] arrForth = new float[arrFirst.Length];
//float temp = 0;
float max = arrThird[0];
int index = 0;
for (int x = 0; x < arrFirst[index]; x++)
{
for (int i = 0; i < arrFirst.Length; i++)
{
arrThird[i] = arrFirst[i] / arrSecond[i];
}
for (int j = 0; j < arrThird.Length; j++)
{
if (arrThird[j] > arrThird[index])
{
index = j;
max = arrThird[j];
arrForth[j] = max;
}
if (arrForth[j] == 0)
{
return;
}
else
{
Console.WriteLine(arrForth[j]);
Console.Read();
}
}
arrFirst[index] -= 1;
}
}
}
}
float[] arrFirst = { 3, 2, 6, 4, 1, 9 };
float[] arrSecond = { 7, 14, 7, 12, 5, 22 };
float[] arrThird = arrFirst.Select((x, i) => x / arrSecond[i]).ToArray<float>();
var max = arrThird.Max();
var index = Array.IndexOf(arrThird, max);
Console.WriteLine(max);
Console.Read();
if(index>-1)
arrFirst[index]--;