P1567_统计天数

/*

  • 题目描述
    炎热的夏日,KC 非常的不爽。他宁可忍受北极的寒冷,也不愿忍受厦门的夏天。最近,他开始研究天气的变化。他希望用研究的结果预测未来的天气。
    经历千辛万苦,他收集了连续 N(1≤N≤10^6)天 的最高气温数据。
    现在,他想知道最高气温一直上升的最长连续天数。
    输入格式
    第 1 行:一个整数 N 。1≤N≤10^6
    第 2 行:
    N个空格隔开的整数,表示连续 N 天的最高气温。
    输出格式
    1 行:一个整数,表示最高气温一直上升的最长连续天数。
    输入输出样例
    输入 #1
    复制
    10
    1 2 3 2 4 5 6 8 5 9
    输出 #1
    复制
    5
    */
朱茂强 QQ:896228072(望大牛多多指教)
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class P1567统计天数 {

	public static void main(String[] args) throws IOException {
		// TODO Auto-generated method stub
		BufferedReader input = new BufferedReader(new InputStreamReader(System.in));
		int n = input.read();
		input.readLine();
		String str[] = input.readLine().split("\\s");
		int max = 0;
		int count = 1;
		for (int i = 1; i <n; i++) {
			if (i == str.length) {
				max = Math.max(max, count);
				count = 1;
				break;
			}

			if (Integer.parseInt(str[i]) > Integer.parseInt(str[i - 1])) {
				count++;
			} else {
				max = Math.max(max, count);
				count = 1;
			}
		}
		System.out.println(max);

	}
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

朱茂强

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值