求最大遞增數


public class LookForMaxIncrease {


	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		String str = scan.next();

		int v = 0, maxv = 0;
		int i;
		for (i = 0; i < str.length() - 1; i++) {
			v = v * 10 + str.charAt(i) - '0';
			if (str.charAt(i) >= str.charAt(i + 1)) {
				if (v > maxv) {
					maxv = v;
				}
				v = 0;
			}
		}
		System.out.println(maxv);

	}

}


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章