模拟考试第一道程序员,求大佬解答

import java.util.Scanner;public class Main { public static void main(String[] args) {        Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
if(n<1||n>100000){ System.out.println("输入错误");
return ;}
long A[]=new long[n];
for(int i = 0; i < n; i ){
A[i] = sc.nextLong();
if( A[i]<1|| A[i]>1000000000)
{
System.out.println("输入错误");
return ; }         }
int count=1;
for(int i=1;i<n-1;i )
{
if((A[i]>A[i-1]&&A[i]>A[i 1])||(A[i]<A[i-1]&&A[i]<A[i 1]))
{ count ;               i ; }
}
System.out.println(count);
}}
全部评论
https://www.nowcoder.com/discuss/27498  这里有标答
点赞 回复
分享
发布于 2017-05-24 19:56

相关推荐

点赞 收藏 评论
分享
牛客网
牛客企业服务