![](https://img-blog.csdnimg.cn/20201014180756927.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
Java基础
Varpb
大数据从入门到放弃
展开
-
求最大值和次大值
求最大值和次大值步骤java代码实现public static void main(String[] args) { int[] a = {7, 4, 1, 9, 6, 5, 11, 2, 12, 8, 3, 10}; //求次大值 int max = -1; int second = -1; for (int i = 0; i < a.length; i++) { if(a[i] >原创 2020-11-30 15:30:28 · 1671 阅读 · 0 评论 -
数据结构(线性表)——令A = AUB
Problem Description将所有在线性表Lb中但不在La中的元素插入到La中线性表无序思路思路:遍历b数组元素,若为a数组中不存在的(二分查找:先排序(希尔排序),再查找),则插入public static void main(String[] args) { int[] a = {1,9,5,3,7}; int[] b = {2,7,5,10,9}; a =...原创 2020-05-04 11:07:29 · 397 阅读 · 0 评论 -
数据结构(线性表)——2.归并两个数组
Problem DescriptionLa与Lb为按值非递减有序排列要求将La和Lb归并为一个新的线性表Lc,且Lc中的数据元素仍按值非递减有序排列public static void main(String[] args) { int[] a = {3,5,8,11}; int[] b = {2,6,8,9,11,15,20}; int[] c = new int[a.le...原创 2020-05-04 11:03:40 · 416 阅读 · 0 评论 -
自己实现java中trim方法
自己实现Java中trim()方法思想str转换成数组while循环获取第一个和最后一个不为空格的元素的位序调用subString方法,实现去除字符串两端的空格。java代码实现public class Demo2 { public static void main(String[] args) { Scanner sc = new Scanner(System.in);...原创 2020-04-23 22:56:29 · 998 阅读 · 0 评论 -
为什么~6 = -7
一些概念和公式正数的原码、反码、补码相同负数的反码:原码除符号位外按位取反负数的补码:反码+1在计算机中,数值一律用补码来表示存储~6在计算机中的计算计算机拿到6的补码,即00000110对6的补码进行“~”计算(按位取反),得到11111001结果已经得到了,只不过是一个补码形式,所以接下来要把补码转换成原码,由上述公式得到原码为:10000111已经得到结果的二进制,将...原创 2020-04-20 10:27:45 · 3183 阅读 · 1 评论