代码考核
表名: stu_score
name course score
张三 数学 70
张三 语文 58
张三 英语 90
李四 数学 80
李四 语文 82
1. 找出平均成绩大于60分的学生
SELECT name FROM stu_score GROUP BY name having AVG(score) > 60;
2. 找出所有成绩都大于60分的学生
SELECT name FROM stu_score GROUP BY name HAVING MIN(score) > 60;
3. 找出数学成绩比语文成绩高的学生
SELECT a.name FROM stu_score a, stu_score b WHERE a.name=b.name AND a.course='数学' AND b.course='语文' AND a.score > b.score;
数组中,找出两数之和为 k 值的两个元素
class Main{
public static void main(String[] args){
int[] a = {1,2,3,4,5};
int k = 6;
int[] ans = new int[2];
ans=fun(a, k);
System.out.print(ans[0] + "+" + ans[1] + "=" + k);
}
public static int[] fun(int a[], int k){
int[] res = new int[2];
for(int i = 0;i < a.length - 1;i++){
for(int j = i + 1;j < a.length;j++){
if(a[i] + a[j] == k){
res[0] = a[i];
res[1] = a[j];
return res;
}
}
}
return res;
}
}
联想公司福利 1500人发布