济南网站制作网站,建站神器,怎么做网站的导航,龙岩app开发定制文章目录 一、选择1.2.#xff08;写错#xff09;3.4.5.6.#xff08;不会#xff09;7.#xff08;不清晰#xff09;8. #xff08;不会#xff09;9.10.#xff08;写错#xff09; 二、编程1. 排序子序列解法#xff1a;代码#xff1a; 2. 倒置字符串解法写错3.4.5.6.不会7.不清晰8. 不会9.10.写错 二、编程1. 排序子序列解法代码 2. 倒置字符串解法代码 一、选择
1. 正确答案D2.写错 正确答案B因为 toLowerCase 在转化完之后是创建了一个新的对象 所以这两个肯定不同
3. 正确答案A静态方法的调用不依赖于任何对象
4. 正确答案A5. 正确答案B6.不会 正确答案D静态成员变量不能再方法中 应该在类中
7.不清晰 正确答案DAabstract 不能修饰字段 B抽象方法不能加{}
8. 不会 正确答案CAclass 中的 constructor 可以省略 Bconstructor 与 class 同名方法也可以
9. 正确答案A10.写错 正确答案D要实现接口肯定得是 public 修饰
二、编程
1. 排序子序列 原题链接 解法
首先我们要知道什么是非递增排列什么是非递减排列
12345 就是递增排列 98765 就是递减排列
12334588 就是非递增排列 987765521 就是非递增排列
非递减就是 a[i]a[i1] 递减就是 a[i]a[i1] 非递增就是 a[i]a[i1] 递增就是 a[i]a
要循环判断arr[i] 与arr[i1] 的大小 注意不要数组越界 代码
import java.util.Scanner;// 注意类名必须为 Main, 不要有任何 package xxx 信息
public class Main {public static void main(String[] args) {Scanner in new Scanner(System.in);// 注意 hasNext 和 hasNextLine 的区别while (in.hasNextInt()) { // 注意 while 处理多个 caseint n in.nextInt();int[] arr new int[n 1];for (int i 0; i n; i) {arr[i] in.nextInt();}int i 0;int count 0;while(i n) {//非递减if(arr[i] arr[i1]) {while(i n arr[i] arr[i 1]) {i;}count;i;}else if(arr[i] arr[i1]) {i;}else {while(i n arr[i] arr[i 1]) {i;}count;i;}}System.out.println(count);}}
}2. 倒置字符串 原题链接 解法
使用字符串分割将字符串以 空格 分开 在把字符数组逆序输出 代码
import java.util.Scanner;// 注意类名必须为 Main, 不要有任何 package xxx 信息
public class Main {public static void main(String[] args) {Scanner in new Scanner(System.in);// 注意 hasNext 和 hasNextLine 的区别while (in.hasNextLine()) { // 注意 while 处理多个 caseString s in.nextLine();int count 0;char[] ch s.toCharArray();for(int i 0; i ch.length; i) {if(ch[i] ) {count;}}String[] ret s.split( ,count 1);int m ret.length;for(int i m - 1; i 0; i--) {System.out.print(ret[i] );}}}
}