分享
这次面试我也做了一些总结,确实还有很多要学的东西。相关面试题也做了整理,可以分享给大家,了解一下面试真题,想进大厂的或者想跳槽的小伙伴不妨好好利用时间来学习。学习的脚步一定不能停止!
Spring Cloud实战
Spring Boot实战
面试题整理(性能优化+微服务+并发编程+开源框架+分布式)
static int dot; // 顶点的值
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
while(true) {
int x = sc.nextInt();
int y = sc.nextInt();
System.out.println(f(x,y));
}
}
public static int f(int x,int y) {
// 原点
if(x0 && y0) return 0;
// 右半部
if(x>0 && x>=Math.abs(y)){
return d1(x,y);
}// 上半部
if(y>0 && y>=Math.abs(x)){
return d2(x,y);
}// 左半部
if(x<0 && -x>Math.abs(y)){
return d3(x,y);
}// 下半部
if(y<0 && -y>=Math.abs(y)){
return d4(x,y);
}return -1;
}
// 右半部 范围:x>0 && x>=Math.abs(y)
public static int d1(int x,int y) {
//第一象限上的顶点
dot = (int) Math.pow(2*x, 2);
if(x==y) return dot; // 第一象限顶点
return dot+x-y; // 第一、四象限
}
// 上半部 范围:y>0 && x>=Math.abs(y)
public static int d2(int x,int y) {
//第二象限上的顶点
dot = (int) Math.pow(2y, 2) - 2y;
if(-x==y) return dot; // 第二象限顶点
return dot+y+x; // 第一、二象限
}
// 左半部 范围:x<0 && -x>=Math.abs(y)
public static int d3(int x,int y) {
//第三象限上的顶点
dot = (int) Math.pow(-x*2-1, 2);
if(x==y-1) return dot; // 第三象限顶点
else if(y<0) return dot-y; // 第三象限
return dot-x+y-1; // 第二象限
}
// 下半部 范围:y<0 && -y>=Math.abs(y)
public static int d4(int x,int y) {
//第四象限上的顶点
dot = (int) Math.pow(2y, 2) - 2y;
if(x==-y) return dot; // 第四象限顶点
return dot-y-x; // 第三、四象限
}
}
运行结果
0 0
0
-1 0
1
-1 1
2
0 1
3
1 1
4
1 0
5
1 -1
6
0 -1
7
-1 -1
8
-2 -1
9
-2 0
10
-2 1
11
-2 2
12
-1 2
13
0 2
14
总结
对于面试还是要好好准备的,尤其是有些问题还是很容易挖坑的,例如你为什么离开现在的公司(你当然不应该抱怨现在的公司有哪些不好的地方,更多的应该表明自己想要寻找更好的发展机会,自己的一些现实因素,比如对于我而言是现在应聘的公司离自己的家更近,又或者是自己工作到达了迷茫期,想跳出迷茫期等等)
Java面试精选题、架构实战文档
整理不易,觉得有帮助的朋友可以帮忙点赞分享支持一下小编~
你的支持,我的动力;祝各位前程似锦,offer不断!
**