網頁設計的動態(tài)網站怎么做騰訊企點官網下載
1.MySQL概述
1.數(shù)據(jù)庫基本概念:存儲數(shù)據(jù)的倉庫,數(shù)據(jù)是有組織的進行存儲
2.數(shù)據(jù)庫管理系統(tǒng):操縱和管理數(shù)據(jù)庫的大型軟件
3.SQL:操作關系型數(shù)據(jù)庫的編程語言,定義了一套操作型數(shù)據(jù)庫統(tǒng)一標準
2.MySQL數(shù)據(jù)庫
關系型數(shù)據(jù)庫(RDBMS):
概念:建立在關系型模型基礎上,由多張相互連接的二維表組成的數(shù)據(jù)庫
好處:1.用表存儲數(shù)據(jù),方便維護
? ? ? ? ? ? 2.用SQL語言操作,標準統(tǒng)一,使用方便
基于表進行數(shù)據(jù)存儲的數(shù)據(jù)庫就是關系型數(shù)據(jù)庫
3.分類
DDL:數(shù)據(jù)定義語言,用來定義數(shù)據(jù)庫對象
DML:數(shù)據(jù)操作語言,用來對數(shù)據(jù)庫表中的數(shù)據(jù)進行增刪查
DQL:數(shù)據(jù)查詢語言,用來潮汛數(shù)據(jù)庫表中記錄
DCL:數(shù)據(jù)控制語言,創(chuàng)建數(shù)據(jù)庫用戶,控制數(shù)據(jù),庫訪問權限
4.DDL語言相關操作
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.內部類
內部類
類里面:成員內部類 ,靜態(tài)內部類(區(qū)別就是是否有static)
方法里面:匿名內部類,局部內部類(匿名內部類沒有類名,局部內部類有)
class Outer{ //外部類public class Inner{ //內部類 (這里是成員內部類)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; //外部類對象創(chuàng)建Outer.Inner inner = outer.new Inner() //內部類對象的創(chuàng)建}
}
1.局部內部類
可以直接訪問外部類的所有成員,包含私有的
不能添加訪問修飾符,因為他的地位就是一個局部變量,但是可以用final修飾
作用域,僅僅在定義他的方法或者代碼塊里面
局部內部類訪問外部類的成員–>直接訪問
外部類訪問局部內部類,在局部內部類的作用域內創(chuàng)建對象然后訪問
局部內部類里的屬性和外部類屬性重名,怎么搞?solution:外部類名.this.屬性名,你可能會有疑問,為什么不能直接this.屬性名,因為局部內部類他始終是一個局部變量,創(chuàng)建它的對象只能在方法體內或者代碼塊內,調用的時候也是外部類的對象調用這個方法進而使用這個對象,所以用this.屬性名的this指的是方法體中創(chuàng)建的局部內部類對象,但是你加上一個外部類名的話,就能表示這個this是外部類的對象
2.匿名內部類
2.1基于接口的匿名內部類
引入:一般情況下你要實現(xiàn)一個接口是寫一個類實現(xiàn)接口,然后創(chuàng)建類的對象實例來使用。但是我現(xiàn)在的需求是只想使用一次,后面不再使用這個類,那我們就引入了匿名內部類
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
最小生成樹模版題,但是需要進行路徑壓縮(狀態(tài)壓縮)不然會被卡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;
}
?
?
?
?
?