话不多说直接上题目:
乍一看这道题似乎很简单,对啊,不就是判断相邻数字之间的大小关系嘛,然后楼主开始写代码,提交,一气呵成,但是测评结果出来后傻眼了…
唔,emmm,先把代码给大家看看(本人新手,捂脸.jpg)
import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int a = sc.nextInt();
int sum = 1,test = 1;
int []b = new int[a];
for(int i=0;i<a;i++) {
b[i] = sc.nextInt();
}
for(int i=0;i<a-1;i++) {
if(b[i]<b[i+1]) {
test++;
} else {
if(test>sum) {
sum = test;
}
test = 1;
}
}
System.out.println(sum);
}
}
(很中规中矩的代码,完全符合小白的思想,但就是不过)
经过询问大佬,才知道,应该用流!!!
流有一个很常见的用法。用于基本的输入操作!(比如:ACM编程中,输入效率比较高。)
BufferedReader provides quite fast read operations for almost all problems. But this class may be used to read single characters and lines only. To read tokens and numbers you should use StringTokenizer orStreamTokenizer.
直接上代码,大家自行体会
import java.io.*;
public class Main {
public static void main(String[] args) throws IOException {
int []a;
StreamTokenizer sc = new StreamTokenizer(new BufferedReader(new InputStreamReader(System.in)));
sc.nextToken