最近夏⽇炎热,令张三⾮常的不爽。最近张三开始研究天⽓的变化。 历经千⾟万苦,他收集了连续N(1<N<1000000)天的最⾼⽓温数据。 现在他想知道气温一直上升的最长连续天数。
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace _011最长气温连续上升天数
{
class Program
{
static void Main(string[] args)
{
string str = Console.ReadLine();
string[] strArray = str.Split(' ');//将字符串按指定的分隔符进行分割
int[] intArray = new int[strArray.Length];
for(int i=0;i<strArray.Length;i++)
{
int number = Convert.ToInt32(strArray[i]);
intArray[i] = number;
}
int count = 1;//记录气温连续升高的天数
int maxCount = 0;//记录最高的气温连续升高的天数
for (int i=0;i<intArray.Length -1;i++)
{
if(intArray[i]<intArray[i+1])
{
count++;
}
else
{
if(count>maxCount )
{
maxCount = count;
}
count = 1;
}
}
if(count >maxCount )
{
maxCount = count;
}
Console.WriteLine("最高天数:" + maxCount);
Console.ReadKey();
}
}
}