sc

mySql随堂练习(3)

假装没事ソ 提交于 2019-12-05 03:13:10
create database xuexiao; use xuexiao; create table sc (sno varchar(20), cno varchar(20), grade int); create table course (cno varchar(20), cname varchar(20), hours int); create table student (sno varchar(20), sname varchar(20), ssex char(10), sage int, sdept varchar(20)); insert into student values("9512101","李1","男",19,"计算机系"),("9512102","刘晨","男",20,"计算机系"), ("9512103","王2","女",20,"计算机系"),("9512103","王敏","女",20,"计算机系"), ("9521101","张3","男",22,"信息系"),("9521102","吴宾","女",21,"信息系"), ("9521103","张4","男",20,"信息系"),("9531101","钱小力","女",18,"数学系"), ("9531102","王大","男",19,"数学系"); insert into course

实验用数据库内容

匿名 (未验证) 提交于 2019-12-02 22:06:11
1 create table student(sno char(9) primary key,sname char(20) unique,ssex char(2),sage smallint, sdept char(20)); 2 create table course(cno char(4) primary key,cname char(40) not null,cpno char(4),ccredit smallint,foreign key(cpno) references course(cno)); 3 create table sc(sno char(9),cno char(4),grade smallint,primary key(sno,cno),foreign key(sno) references student(sno),foreign key(cno) references course(cno)); 4 5 insert into course values('1','数据库','5','4.0'); 6 insert into course values('2','高等数学','NULL','2.0'); 7 insert into course values('3','信息系统','1','4.0'); 8 insert into course

京东笔试题

北城余情 提交于 2019-11-28 11:12:56
1. 合唱队 题目 大意: 将数组分成若干个数组 ,子数组内部从小到大排序,使所有子数组整体按非递减顺序,求子数组最大数量; 输入 4 2 1 3 2 输出 2 输入 10 69 230 77 650 440 270 750 760 990 880 输出 6 代码: import java.util.Scanner; public class B9 { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); sc.nextLine(); String[] str = sc.nextLine().split(" "); long[] val = new long[n]; for (int i = 0; i < n; i++) { val[i] = Long.valueOf(str[i]); } int[] positions = new int[n]; int count = 0; int index = 0; while(index< n-1){ long min = Long.MAX_VALUE; int i = index; for (; i < n; i++) { if(min> val[i]){ min = val[i];

「学习笔记」杂项算法大礼包

纵饮孤独 提交于 2019-11-28 01:15:22
平面最近点对。 #include <algorithm> #include <cstdio> #include <vector> #include <cmath> using namespace std; #define fs first #define sc second typedef double db; typedef pair<db, db> pa; const int N = 2e5 + 10; const db EPS = 1e-10; int cmp1(pa a, pa b) { return a.fs - b.fs < -EPS; } int cmp2(pa a, pa b) { return a.sc - b.sc < -EPS; } int n, m; pa a[N], arr[N]; db p(db x) { return x * x; } db d(pa x, pa y) { return sqrt(p(x.fs - y.fs) + p(x.sc - y.sc)); } db divide(int l, int r) { if(r - l <= 2) { db ans = 3e18; for(int i = l; i < r; i ++) for(int j = i + 1; j <= r; j ++) ans = min(ans, d(a[i], a[j

键盘录入

狂风中的少年 提交于 2019-11-28 00:29:52
import java.util.Scanner; Scanner sc = new Scanner (System.in); int i = sc.nextInt(); String str = sc.next(); double ddd = sc.nextDouble(); char ccc = 'y'; 来源: https://www.cnblogs.com/comw/p/11382774.html

mysql 聚集函数和分组

不羁岁月 提交于 2019-11-27 01:08:40
1、sc表的内容如下: mysql> select * from sc order by sid asc; +----+-------+-----+-------+ | ID | SID | CID | SCORE | +----+-------+-----+-------+ | 1 | 10001 | 101 | 70 | | 2 | 10001 | 102 | 80 | | 4 | 10001 | 103 | 90 | | 3 | 10008 | 103 | 50 | | 5 | 10008 | 101 | 60 | | 6 | 10008 | 102 | 70 | +----+-------+-----+-------+ 6 rows in set 2、求所有成绩的平均值 mysql> select avg(score) from sc; +------------+ | avg(score) | +------------+ | 70.0000 | +------------+ 1 row in set 考虑,select sid,cid,avg(score) from sc;的结果是什么? 这个时候平均值只有一个,而sid,cid都是有多个,这种情况,sid,cid取第一条记录的值,sid,cid的值也没有意义。如果某一列所有的值都相同,才有意义。 3