/images/avatar.png

^_^

mysql查询练习

数据准备

数据库

test3

建表

学生表 课程表 成绩表 教师表
Student Course Score Teacher
学号 课程号 学号 教师编号
姓名 课程名称 课程号 教师名字
性别 教师编号 成绩 教师性别
出生年月日 出生年月日
所在班级 职称
所在部门

学生表

https://img-blog.csdnimg.cn/20201120101323394.png#pic_center

mysql基础

基本操作

进入数据库

1
mysql -uroot -p123456;

查看所有数据库

1
show databases;

使用某个数据库

1
use XXX;

查看某个数据库中的admin信息

1
select * from admin;

带条件的查询

1
select * from admin where id = 1;

mysql数据类型

链家

查看当前在哪个数据库

https://img-blog.csdnimg.cn/20201120093303559.png#pic_center

查看数据库中有哪些表

https://img-blog.csdnimg.cn/202011200933260.png#pic_center

abc170

A - Five Variables

题意

找5个数中值为0的下标

题解

1
2
a = list(map(int , input().split()))
print(a.index(0) + 1)

B - Crane and Turtle

题意

鸡兔同笼问题

题解

1
2
n , m = map(int , input().split())
print('Yes') if (m - 2 * n) % 2 == 0 and (m - 2 * n) >= 0 and 4 * n - m >= 0 and (4 * n - m) % 2 == 0 else print('No')

C - Forbidden List

题意

给一数x 和一数列,找不在数列中离x最近的数

题解

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
x , n = map(int , input().split())
b = []
if n!=0:
    b = list(map(int,input().split()))
t = 0
ans = 0
while 1:
    if x-t not in b:
        ans = x - t
        break
    if x+t not in b:
        ans = x + t
        break
    t += 1
print(ans)

D - Not Divisible

题意

给一数列,对于数列中的每个数,如果都不能被其他数整除,计数器 + 1

Flask-RESTful简单实例

Python web的框架有Django Flask Tornado

Flask 是一个使用 Python 编写的轻量级 Web 应用程序框架,由werkzeug服务器和jinja2模板引擎组成

RESTful是一个与资源(resource)有关的架构理念

Flask学习

扩展的地址

flask扩展的地址

requirement.txt

用来存项目的依赖和版本

生成requirement.txt

1
pip freeze > requirement.txt

安装requirement.txt

1
pip install -r requirement.txt

基本框架

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
from flask import Flask

app = Flask(__name__)

@app.route('/')
def index():
    return 'hello world'

if __name__ == '__main__':
    app.run()

Flask-RESTful

Python学习

记录一下第n次学python。。。

打印

转义字符的打印

1
2
3
4
5
6
str = r"D:\now"
print(str)

------------------------------

D:\now

数据类型

获得数据类型

1
2
3
4
5
6
7
print(type(3.14))
print(isinstance(15, int))

-----------------------------------

<class 'float'>
True

运算符

整数除法 幂次 大小关系表达式

1
2
3
4
5
6
7
8
9
print(3//2)
print(-3**3)
print(3<4<5)

--------------------------

1
-27
True

三目运算符

1
2
3
4
5
6
x = 6 if 2 > 4 else 7
print(x)

--------------------------------

7

运算符的优先级

https://img-blog.csdnimg.cn/20210205223244414.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3FxXzQzNzM3Njk3,size_16,color_FFFFFF,t_70

每日一题 (X)

堆 贪心

题目

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
ll n;
struct p{
    ll v,s;
}ps[100005];
bool cmp(p a,p b){return a.s>b.s;}
priority_queue<ll , vector<ll> , greater<ll> > pq;
int main(){
    cin>>n;
    for(ll i=0;i<n;i++) cin>>ps[i].v>>ps[i].s;
    
    sort(ps,ps+n,cmp);
    
    ll temp=0,ans=0;
    for(ll i=0;i<n;i++){
        temp+=ps[i].v;
        pq.push(ps[i].v);
        
        while(pq.size()>ps[i].s){
            temp-=pq.top();
            pq.pop();
        }
        
        ans=max(ans,temp);
    }
    cout<<ans<<endl;
    return 0;
}

===========================================================================================================

Codeforces Round #644 (Div. 3)

可能是最简单的div3(不考dp dfs?)

A. Minimal Square

题意

给俩相同的长方形,求面积最小的正方形使得容纳两个长方形,且长方形之间不重合

题解

两倍宽或两倍长

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
int  main(){
	int t;
	cin>>t;
	while(t--){
		int a,b;
		cin>>a>>b;
		if(a>b) swap(a,b);
		if(2*a<=b) cout<<b*b<<endl;
		else  cout<<4*a*a<<endl;
	}
	return 0;
}

B. Honest Coach

题意

把一堆数分成两堆,求第一堆最大值和第二堆最小值的差的最小值

abc168

A - ∴ (Therefore)

题意

看题目

题解

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
#include<bits/stdc++.h>
using namespace std;
int main(){
	string s;
	cin>>s;
	char c=s[s.length()-1];
	switch(c){
		case '2' :case '4': case '5': case '7': case '9': 
			cout<<"hon\n";
			break;
		case '3':
			cout<<"bon\n";
			break;
		default :cout<<"pon\n"; 
	}
	return 0;
}

B - … (Triple Dots)

题意

看题目

题解

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
#include<bits/stdc++.h>
using namespace std;
int main(){
	int k;
	cin>>k;
	string s;
	cin>>s;
	
	if(s.length()<=k)cout<<s<<endl;
	else{
		for(int i=0;i<k;i++){
			cout<<s[i];
		}cout<<"..."<<endl;
	}
	
	return 0;
}

C - : (Colon)

题意

给定时针和分针的长度,起始为12点,问经过h小时m分钟后,时针和分针不连接的端点的距离