链接: https://pan.baidu.com/s/1CUtqB-2ydwyrEQI9i7R6hA
提取码: cbxg
链接: https://pan.baidu.com/s/1CUtqB-2ydwyrEQI9i7R6hA
提取码: cbxg
public static void Test()
{
List<int> list1 = new List<int>();
List<int> list2 = new List<int>();
bool flag_increase=false, flag_decrease=false, flag_equal=false;
while (true)
{
string str=Console.ReadLine();
if (str=="")
{
break;
}
try
{
string[] strs = str.Split(' ');
int i, j;
i = int.Parse(strs[0]);
j = int.Parse(strs[1]);
list1.Add(i);
list2.Add(j);
}
catch (Exception)
{
}
}
for (int i = 0; i < list1.Count - 1; i++)
{
if (((float)list1[i] / (float)list2[i]) < ((float)list1[i + 1] / (float)list2[i + 1]))
{
flag_increase = true;
}
else if (((float)list1[i] / (float)list2[i]) > ((float)list1[i + 1] / (float)list2[i + 1]))
{
flag_decrease = true;
}
else
{
flag_equal = true;
}
}
if (flag_increase && !flag_decrease && !flag_equal)
{
Console.WriteLine("increasing");
}
else if (!flag_increase && flag_decrease && !flag_equal)
{
Console.WriteLine("decreasing");
}
else if (!flag_increase && !flag_decrease && flag_equal)
{
Console.WriteLine("constant");
}
else if (flag_increase && !flag_decrease && flag_equal)
{
Console.WriteLine("non-decreasing");
}
else if (!flag_increase && flag_decrease && flag_equal)
{
Console.WriteLine("non-increasing");
}
else
{
Console.WriteLine("non-monotonic");
}
}