網(wǎng)頁(yè)設(shè)計(jì)的動(dòng)態(tài)網(wǎng)站怎么做騰訊企點(diǎn)官網(wǎng)下載
1.MySQL概述
1.數(shù)據(jù)庫(kù)基本概念:存儲(chǔ)數(shù)據(jù)的倉(cāng)庫(kù),數(shù)據(jù)是有組織的進(jìn)行存儲(chǔ)
2.數(shù)據(jù)庫(kù)管理系統(tǒng):操縱和管理數(shù)據(jù)庫(kù)的大型軟件
3.SQL:操作關(guān)系型數(shù)據(jù)庫(kù)的編程語(yǔ)言,定義了一套操作型數(shù)據(jù)庫(kù)統(tǒng)一標(biāo)準(zhǔn)
2.MySQL數(shù)據(jù)庫(kù)
關(guān)系型數(shù)據(jù)庫(kù)(RDBMS):
概念:建立在關(guān)系型模型基礎(chǔ)上,由多張相互連接的二維表組成的數(shù)據(jù)庫(kù)
好處:1.用表存儲(chǔ)數(shù)據(jù),方便維護(hù)
? ? ? ? ? ? 2.用SQL語(yǔ)言操作,標(biāo)準(zhǔn)統(tǒng)一,使用方便
基于表進(jìn)行數(shù)據(jù)存儲(chǔ)的數(shù)據(jù)庫(kù)就是關(guān)系型數(shù)據(jù)庫(kù)
3.分類
DDL:數(shù)據(jù)定義語(yǔ)言,用來(lái)定義數(shù)據(jù)庫(kù)對(duì)象
DML:數(shù)據(jù)操作語(yǔ)言,用來(lái)對(duì)數(shù)據(jù)庫(kù)表中的數(shù)據(jù)進(jìn)行增刪查
DQL:數(shù)據(jù)查詢語(yǔ)言,用來(lái)潮汛數(shù)據(jù)庫(kù)表中記錄
DCL:數(shù)據(jù)控制語(yǔ)言,創(chuàng)建數(shù)據(jù)庫(kù)用戶,控制數(shù)據(jù),庫(kù)訪問(wèn)權(quán)限
4.DDL語(yǔ)言相關(guān)操作
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| biaoge |
| information_schema |
| mysql |
| performance_schema |
| sys |
+--------------------+
5 rows in set (0.00 sec)
mysql> create database test;
Query OK, 1 row affected (0.01 sec)mysql> show databases;
+--------------------+
| Database |
+--------------------+
| biaoge |
| information_schema |
| mysql |
| performance_schema |
| sys |
| test |
+--------------------+
6 rows in set (0.00 sec)
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| biaoge |
| information_schema |
| mysql |
| performance_schema |
| sys |
| test |
| test1 |
+--------------------+
7 rows in set (0.00 sec)
mysql> select database();
+------------+
| database() |
+------------+
| biaoge |
+------------+
1 row in set (0.00 sec)mysql> show tables;
+------------------+
| Tables_in_biaoge |
+------------------+
| testbiaoge |
+------------------+
1 row in set (0.00 sec)mysql> desc testbiaoge;
+-------+-------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-------+-------------+------+-----+---------+-------+
| name | varchar(50) | YES | | NULL | |
| ID | int | NO | PRI | NULL | |
| score | int | YES | | NULL | |
+-------+-------------+------+-----+---------+-------+
3 rows in set (0.00 sec)
?5.內(nèi)部類
內(nèi)部類
類里面:成員內(nèi)部類 ,靜態(tài)內(nèi)部類(區(qū)別就是是否有static)
方法里面:匿名內(nèi)部類,局部?jī)?nèi)部類(匿名內(nèi)部類沒有類名,局部?jī)?nèi)部類有)
class Outer{ //外部類public class Inner{ //內(nèi)部類 (這里是成員內(nèi)部類)int age = 1; }public void test(){Inner inner = new Inner();System.out.println(inner.age);}public static void main(String[] args){Outer outer = new Outer; //外部類對(duì)象創(chuàng)建Outer.Inner inner = outer.new Inner() //內(nèi)部類對(duì)象的創(chuàng)建}
}
1.局部?jī)?nèi)部類
可以直接訪問(wèn)外部類的所有成員,包含私有的
不能添加訪問(wèn)修飾符,因?yàn)樗牡匚痪褪且粋€(gè)局部變量,但是可以用final修飾
作用域,僅僅在定義他的方法或者代碼塊里面
局部?jī)?nèi)部類訪問(wèn)外部類的成員–>直接訪問(wèn)
外部類訪問(wèn)局部?jī)?nèi)部類,在局部?jī)?nèi)部類的作用域內(nèi)創(chuàng)建對(duì)象然后訪問(wèn)
局部?jī)?nèi)部類里的屬性和外部類屬性重名,怎么搞?solution:外部類名.this.屬性名,你可能會(huì)有疑問(wèn),為什么不能直接this.屬性名,因?yàn)榫植績(jī)?nèi)部類他始終是一個(gè)局部變量,創(chuàng)建它的對(duì)象只能在方法體內(nèi)或者代碼塊內(nèi),調(diào)用的時(shí)候也是外部類的對(duì)象調(diào)用這個(gè)方法進(jìn)而使用這個(gè)對(duì)象,所以用this.屬性名的this指的是方法體中創(chuàng)建的局部?jī)?nèi)部類對(duì)象,但是你加上一個(gè)外部類名的話,就能表示這個(gè)this是外部類的對(duì)象
2.匿名內(nèi)部類
2.1基于接口的匿名內(nèi)部類
引入:一般情況下你要實(shí)現(xiàn)一個(gè)接口是寫一個(gè)類實(shí)現(xiàn)接口,然后創(chuàng)建類的對(duì)象實(shí)例來(lái)使用。但是我現(xiàn)在的需求是只想使用一次,后面不再使用這個(gè)類,那我們就引入了匿名內(nèi)部類
public class AnonymousInnerClass {public static void main(String[] args) {IA ia = new IA(){@Overridepublic void wang() {System.out.println("汪汪叫...."); }};}
}interface IA{void wang();
}
?
?每日一題:
Watering the Fields
最小生成樹模版題,但是需要進(jìn)行路徑壓縮(狀態(tài)壓縮)不然會(huì)被卡TLE
#include<bits/stdc++.h>
using namespace std;
long long n;
long long c;
long long x[2005];
long long y[2005];
long long f[4000001];
long long cnt;
long long sum;
long long ans;
long long flag;
struct lu
{int a,b;long long w;
}q[4000005];int cha(int x)
{if(f[x] == x)return x;return f[x] = cha(f[x]);//路徑壓縮
}void bing(int r1,int r2)
{if(r1==r2)return ;f[r2]=r1;
}bool cmp(lu x,lu y)
{return x.w<y.w;
}int main()
{cin>>n>>c;for(int i=1;i<=n;i++)f[i]=i;for(int i=1;i<=n;i++){cin>>x[i]>>y[i];for(int j=1;j<i;j++){long long dis=((x[i]-x[j])*(x[i]-x[j])+(y[i]-y[j])*(y[i]-y[j]));if(dis>=c){cnt++;q[cnt].a=i;q[cnt].b=j;q[cnt].w=dis;}}}if(cnt<n-1){printf("-1\n");return 0;}sort(q+1,q+1+cnt,cmp);for(int i=1;i<=cnt;i++){int x=cha(q[i].a);int y=cha(q[i].b);if(x!=y){bing(x,y);sum+=q[i].w;ans++;if(ans==n-1)break;}}if(ans==n-1)printf("%lld\n",sum);elseprintf("-1\n");return 0;
}
?
?
?
?
?