double a = Math.pow(s*(s-s1)(s-s2)(s-s3),0.5);
return a;
}
}
=================================================================
import java.util.Scanner;
public class dibazhang {
public static void main(String[] args) {
System.out.println("Enter x1, y1, x2, y2, x3, y3, x4, y4: ");
double[][] points = new double[4][2];
Scanner input = new Scanner(System.in);
for (int i = 0; i < 4; i++) {
for (int j = 0; j < 2; j++) {
points[i][j] = input.nextDouble();
}
}
double array[] = getIntersectingPoint(points);
// System.out.print(“Intersecting point: (”);
// for (int i = 0; i < 2; i++) {
// if (i == 1) {
// System.out.print(array[i] + ") ");
// } else {
// System.out.print(array[i] + “,”);
// }
// }
double x = array[0];
double y = array[1];
double x1 = points[0][0];
double y1 = points[0][1];
double x2 = points[1][0];
double y2 = points[1][1];
double x3 = points[2][0];
double y3 = points[2][1];
double x4 = points[3][0];
double y4 = points[3][1];
double[] S = new double[4];
S[0] = Math.abs((x1y2 + x2y + xy1 - x1y - x2y1 - xy2) / 2);
S[1] = Math.abs((x1y4 + x4y + xy1 - x1y - x4y1 - xy4) / 2);
S[2] = Math.abs((x3y2 + x2y + xy3 - x3y - x2y3 - xy2) / 2);
S[3] = Math.abs((x3y4 + x4y + xy3 - x3y - x4y3 - xy4) / 2);
bubble(S);
System.out.println();
System.out.print("The areas are ");
for (int i = 0; i < 4; i++) {
if (i == 3) {
System.out.printf(“%.2f”,S[i]);
} else {
System.out.printf("%.2f ",S[i]);
}
}
}
public static double[] getIntersectingPoint(double[][] points) {
double x1 = points[0][0];
double y1 = points[0][1];
double x2 = points[1][0];
double y2 = points[1][1];
double x3 = points[2][0];
double y3 = points[2][1];
double x4 = points[3][0];
double y4 = points[3][1];
double K1 = (y1 - y3) / (x1 - x3);
double K2 = (y2 - y4) / (x2 - x4);
double[] arr = new double[2];
double B1 = y1 - K1 * x1;
double B2 = y2 - K2 * x2;
arr[0] = (B2 - B1) / (K1 - K2);
arr[1] = (B2 * K1 - B1 * K2) / (K1 - K2);
return arr;
}
public static void bubble(double[] S) {
double temp;
for (int i = 0; i < S.length; i++) {
for (int j = S.length - 1; j > i; j–) {
if (S[j] < S[j - 1]) {
temp = S[j - 1];
S[j - 1] = S[j];
S[j] = temp;
}
}
}
}
}
=================================================================
import java.util.Scanner;
public class dibazhang {
public static void main(String args[]) {
Scanner input = new Scanner(System.in);
System.out.print(“Enter 6 points:”);
double[][] points = new double[6][2];
for (int i = 0; i < 6; ++i) {
points[i][0] = input.nextDouble();
points[i][1] = input.nextDouble();
}
double[] point = getRightmostLowestPoint(points);
System.out.println(“The rightmost lowest point is (”+point[0] + “,” + point[1]+“)”);
}
public static double[] getRightmostLowestPoint(double[][] points) {
double[][] sum = new double[6][3];
for (int i = 0; i < 6; ++i) {
sum[i][0] = points[i][0];
sum[i][1] = points[i][1];
sum[i][2] = Math.abs(points[i][0]) + Math.abs(points[i][0]);
}
selectSort(sum);
double[] result = sum[5];
for (int i = 5; i >= 0; --i) {
if (sum[i][0] >= 0 && sum[i][1] <= 0) {
result = sum[i];
break;
}
}
return result;
}
public static void selectSort(double[][] num) {
for (int i = 0; i < 5; ++i) {
for (int j = i + 1; j < 6; ++j) {
if (num[i][2] > num[j][2]) {
double[] temp = num[i];
num[i] = num[j];
num[j] = temp;
}
}
}
}
}
=================================================================
import java.util.Scanner;
public class dibazhang {
public static void main(String[] args){
Scanner input = new Scanner(System.in);
System.out.print(“Enter the number of rows in the matrix:”);
int n = input.nextInt();
int[][] test = new int[n][n];
System.out.println(“Enter the matrix row by row:”);
for(int i=0;i<n;i++)
for(int j=0;j<n;j++)
test[i][j]=input.nextInt();
int[] jesus = findLargestBlock(test);
System.out.printf(“The maximum square submatrix is at (%d,%d) with size %d\n”,jesus[0],jesus[1],jesus[2]);
}
public static int[] findLargestBlock(int[][] m){
int[] res = new int[3];
int n = m.length;
for(int i=0;i<n;i++)
for(int j=0;j<n;j++){
for(int r=1;r<=Math.min(n-i,n-j);r++){
if(allOne(i,j,r,m)){
if(r>res[2]){
res[0]=i;
res[1]=j;
res[2]=r;
}
}
}
}
return res;
}
public static boolean allOne(int pinr,int pinc, int range,int[][] m){
boolean all1 = true;
for(int i=0;i<range;i++)
for(int j=0;j<range;j++){
if(m[pinr+i][pinc+j]==0){
all1 = false;
break;
}
}
return all1;
}
}
=================================================================
import java.util.Arrays;
import java.util.Scanner;
public class dibazhang {
public static void main(String args[]) {
System.out.print(“Enter number n:”);
Scanner input = new Scanner(System.in);
int n = input.nextInt();
char[][] matrix = new char[n][n];
String temp = null;
System.out.printf(“Enter %d rows of letters separated by spaces: \n”,n);
for (int i = 0; i < n; ++i) {
for (int j = 0; j < n; ++j) {
temp = input.next();
matrix[i][j] = temp.charAt(0);
}
}
int[] record = new int[n];
Arrays.fill(record, 0);
for (int i = 0; i < n; ++i) {
for (int j = 0; j < n; ++j) {
++record[(int) (matrix[i][j] - ‘A’)];
}
}
for (int i = 0; i < n; ++i) {
for (int j = 0; j < n; ++j) {
++record[(int) (matrix[j][i] - ‘A’)];
}
}
boolean flag = true;
for (int i = 0; i < n; ++i) {
if (record[i] != 2 * n) {
flag = false;
}
}
if(flag)
System.out.print(“The input array is a latin square”);
else
System.out.print(“Wrong input: the letters must be from A to C”);
}
}
=================================================================
这个题,自己做太麻烦,所以看了看网上怎么写的,借鉴一下。
import javax.swing.JOptionPane;
public class dibazhang {
public static void main(String[] args) {
String[][] stateCapital = {
//55个州和它们独自的首府
{“Alabama”, “Montgomery”},
{“Alaska”, “Juneau”},
{“Arizona”, “Phoenix”},
{“Arkansas”, “Little Rock”},
{“California”, “Sacramento”},
{“Colorado”, “Denver”},
{“Connecticut”, “Hartford”},
{“Delaware”, “Dover”},
{“Florida”, “Tallahassee”},
{“Georgia”, “Atlanta”},
{“Hawaii”, “Honolulu”},
{“Idaho”, “Boise”},
{“Illinois”, “Springfield”},
{“Indiana”, “Indianapolis”},
{“Iowa”, “Des Moines”},
{“Kansas”, “Topeka”},
{“Kentucky”, “Frankfort”},
{“Louisiana”, “Baton Rouge”},
{“Maine”, “Augusta”},
{“Maryland”, “Annapolis”},
{“Massachusettes”, “Boston”},
{“Michigan”, “Lansing”},
{“Minnesota”, “Saint Paul”},
{“Mississippi”, “Jackson”},
{“Missouri”, “Jefferson City”},
{“Montana”, “Helena”},
{“Nebraska”, “Lincoln”},
{“Nevada”, “Carson City”},
{“New Hampshire”, “Concord”},
{“New Jersey”, “Trenton”},
{“New York”, “Albany”},
{“New Mexico”, “Santa Fe”},
{“North Carolina”, “Raleigh”},
{“North Dakota”, “Bismark”},
{“Ohio”, “Columbus”},
{“Oklahoma”, “Oklahoma City”},
{“Oregon”, “Salem”},
{“Pennslyvania”, “Harrisburg”},
{“Rhode Island”, “Providence”},
{“South Carolina”, “Columbia”},
{“South Dakota”, “Pierre”},
{“Tennessee”, “Nashville”},
{“Texas”, “Austin”},
{“Utah”, “Salt Lake City”},
{“Vermont”, “Montpelier”},
最后
自我介绍一下,小编13年上海交大毕业,曾经在小公司待过,也去过华为、OPPO等大厂,18年进入阿里一直到现在。
深知大多数Java工程师,想要提升技能,往往是自己摸索成长,自己不成体系的自学效果低效漫长且无助。
因此收集整理了一份《2024年Java开发全套学习资料》,初衷也很简单,就是希望能够帮助到想自学提升又不知道该从何学起的朋友,同时减轻大家的负担。
既有适合小白学习的零基础资料,也有适合3年以上经验的小伙伴深入学习提升的进阶课程,基本涵盖了95%以上Java开发知识点,不论你是刚入门Android开发的新手,还是希望在技术上不断提升的资深开发者,这些资料都将为你打开新的学习之门!
如果你觉得这些内容对你有帮助,需要这份全套学习资料的朋友可以戳我获取!!
由于文件比较大,这里只是将部分目录截图出来,每个节点里面都包含大厂面经、学习笔记、源码讲义、实战项目、讲解视频,并且会持续更新!
“Salt Lake City”},
{“Vermont”, “Montpelier”},
最后
自我介绍一下,小编13年上海交大毕业,曾经在小公司待过,也去过华为、OPPO等大厂,18年进入阿里一直到现在。
深知大多数Java工程师,想要提升技能,往往是自己摸索成长,自己不成体系的自学效果低效漫长且无助。
因此收集整理了一份《2024年Java开发全套学习资料》,初衷也很简单,就是希望能够帮助到想自学提升又不知道该从何学起的朋友,同时减轻大家的负担。
[外链图片转存中…(img-AoUOCVmJ-1715449349223)]
[外链图片转存中…(img-Dua6Itkt-1715449349224)]
[外链图片转存中…(img-63jls39P-1715449349224)]
既有适合小白学习的零基础资料,也有适合3年以上经验的小伙伴深入学习提升的进阶课程,基本涵盖了95%以上Java开发知识点,不论你是刚入门Android开发的新手,还是希望在技术上不断提升的资深开发者,这些资料都将为你打开新的学习之门!
如果你觉得这些内容对你有帮助,需要这份全套学习资料的朋友可以戳我获取!!
由于文件比较大,这里只是将部分目录截图出来,每个节点里面都包含大厂面经、学习笔记、源码讲义、实战项目、讲解视频,并且会持续更新!