科大讯飞笔试

做科大讯飞的时候,我真是脑子瓦特了,点到第三题的时候,提交运行,结果把编程题子卷全部提交了,前面两道题还没看,敲,虽然很是无能狂怒,不过还是好好看看这些题吧,这些题是我线下思考了一下写的,没有线上测试过,不能保证AC,有发现问题的同学请提出宝贵的意见:blush:

编程题1

image-20220806193011145

直接暴力循环判断吧

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
public class Solution {
public int calcE(String str) {
int res = 0, temp=0;
char[] strs = str.toCharArray();
for (int i = 0; i < strs.length; i++) {
if (strs[i]=='e' || strs[i] == 'E')
temp = 1;
if (strs[i] = ' ' && temp == 1) {
temp = 0;
res++;
}
}
return res;
}
}

不保证AC

编程题2

image-20220806193117999

将四边形分为两个三角形,然后计算两个三角形面积之和,三角形面积计算通过海伦公式

海伦公式,假设三角形边长分别是a,b,c,则有
$$
s = \frac{a+b+c}{2} \
S_\Delta = \sqrt{s(s-a)(s-b)(s-c)}
$$
最后将double转换为int

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
public class Solution {
public int calcArea(int[] point1, int[] point2, int[] point3, int[] point4) {
double temp = calcTrangle(point1, point2, point3) + calcTrangle(point2, point3, point4);
return (int)Math.ceil(temp);
}

public double calcTrangle(int[] point1, int[] point2, int[] point3) {
double a = calcDistance(point1, point2);
double b = calcDistance(point2, point3);
double c= calcDistance(point1, point3);
double s = (a+b+c)/2;
return Math.sqrt(s*(s-a) * (s-b) * (s-c));

}

public double calcDistance(int[] point1, int[] point2) {
return Math.sqrt((point1[0] - point2[0]) * (point1[0] - point2[0]) + (point1[1] - point2[1]) * (point1[1] - point2[1]));
}

不保证AC

编程题3==宕机==

image-20220806193423392

image-20220806193434327

我也宕机了


科大讯飞2023届秋招研发类笔试试卷A(二)
http://example.com/2022/08/06/笔试记录/科大讯飞2023届秋招研发类笔试试卷A(二)/
作者
madao33
发布于
August 6, 2022
许可协议