20220716第三组张立学习笔记
作者:互联网
知识点
习题
`package com.jr.morning;
public class Ch10 {
public static void main(String[] args) {
char[] arr = new char[]{'a', 'i', 'f', 'm', 'f', 'o', 'b', 'b', 's', 'n'};
int [] count=new int[26];
// printCount(arr);
for (int i = 0; i < count.length; i++) {
if((printCount(arr)[i])!=0){
System.out.println((char)(97+i)+"--"+(printCount(arr)[i]));
}}
}
public static int[] printCount(char[] arr){
int[] counts = new int[26];
for (int i = 0; i < arr.length; i++) {
counts[(char)arr[i]-97]++;
}
return counts;
}
}`
以上为输出数组中字母出现的次数
//两个数组拼接成一个数组在一个数组后面
int [] arr1=new int[]{1,2,4,5,};
int [] arr2=new int[]{6,7,8,9};
// int [] newArr=new int[arr1.length+arr2.length];
// for (int i = 0; i < arr1.length; i++) {
// newArr[i]=arr1[i];
// }
// arr1=newArr;
// for (int j = 0; j < arr2.length ; j++) {
// arr1[arr1.length-1-j]=arr2[arr2.length-1-j];
// }
// System.out.println(Arrays.toString(arr1));
`package com.jr.morning;
import java.util.Arrays;
public class Ch5 {
public static void main(String[] args) {
int [] arr=new int[]{1,45,78,33,22,7898};
for (int index = 1; index <arr.length ; index++) {
while (index>0&&arr[index]<arr[index-1]){
int temp=arr[index];
arr[index]=arr[index-1];
arr[index-1]=temp;
index--;
}
}
System.out.println(Arrays.toString(arr));
}
}
`
插入排序
学习心得
还差很多,继续努力
学习心情
一般,不在状态
标签:第三组,arr,20220716,int,张立,char,length,arr1,new 来源: https://www.cnblogs.com/damecss/p/16485323.html