Skip to content

Commit

Permalink
增加了 iccad, 数据结构和java 回忆
Browse files Browse the repository at this point in the history
  • Loading branch information
LukeLIN-web committed Mar 16, 2021
1 parent c5b7adf commit 6246b32
Show file tree
Hide file tree
Showing 376 changed files with 606,640 additions and 0 deletions.
16 changes: 16 additions & 0 deletions Java应用技术/试卷/2020秋冬.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# 2020秋冬



选择填空大部分在 <基础> 那本书上



3个编程 一个10分.

编程考了 synchronize 同步这个关键词, 要求写deposit 50 并发.

还有一个就是造轮子, 不难. 编程题都不难.



Binary file added 数据结构基础/ppt/&1.ppt
Binary file not shown.
Binary file added 数据结构基础/ppt/&10 graph (2).ppt
Binary file not shown.
Binary file added 数据结构基础/ppt/&11.ppt
Binary file not shown.
Binary file added 数据结构基础/ppt/&12.ppt
Binary file not shown.
Binary file added 数据结构基础/ppt/&2.ppt
Binary file not shown.
Binary file added 数据结构基础/ppt/&3.ppt
Binary file not shown.
Binary file added 数据结构基础/ppt/&4.ppt
Binary file not shown.
Binary file added 数据结构基础/ppt/&5.ppt
Binary file not shown.
Binary file added 数据结构基础/ppt/&6.ppt
Binary file not shown.
Binary file added 数据结构基础/ppt/&7.ppt
Binary file not shown.
Binary file added 数据结构基础/ppt/&8.ppt
Binary file not shown.
Binary file added 数据结构基础/ppt/&9.1 HASH.ppt
Binary file not shown.
Binary file added 数据结构基础/ppt/&9.2Quadratic Probing.ppt
Binary file not shown.
Binary file not shown.
Binary file added 数据结构基础/ppt/ds00.ppt
Binary file not shown.
Binary file added 数据结构基础/ppt/ds01ch02.ppt
Binary file not shown.
470 changes: 470 additions & 0 deletions 数据结构基础/作业/Homework PTA solution and tips.md

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
#include <stdio.h>
#include <stdlib.h>
typedef int ElementType;
typedef struct Node *PtrToNode;
typedef PtrToNode List;
typedef PtrToNode Position;
struct Node {
ElementType Element;
int first;
int Next;
};
List ListConstruct(int data){
if (data == 0){
return NULL;
}
List ret = (List)malloc(sizeof(List));
ret->Element = data;
ret->Next = NULL;
return ret;
}


int BuildNode(int Lh,struct Node node[],struct Node L1[]) {
int count = 0;
while(Lh != -1){
L1[count] = node[Lh];
// printf("node[Lh] = %d , %d , %d \n",node[Lh].first,node[Lh].Element,node[Lh].Next);
Lh = node[Lh].Next;
count ++;
}
return count;
}


List Merge(List List1,List List2){


}

void print(int bigerSize,int reverSize,struct Node L1[],struct Node L2[]){
int i =1;
printf("%05d %d",L1[0].first,L1[0].Element);
for(i=1; i<bigerSize;i++){
printf(" %05d\n%05d %d", L1[i].first, L1[i].first, L1[i].Element);
if(i % 2 == 1 && reverSize >= 0){
printf(" %05d\n%05d %d", L2[reverSize].first, L2[reverSize].first, L2[reverSize].Element);
reverSize--;
}
}
printf(" -1");

}

int main(){
int L1h,L2h,N ,size1,size2,bigerSize,reverSize;
struct Node L1[100];
struct Node L2[100];
struct Node node[123456];
int addr[100],data[100],Next[100];
scanf("%d%d%d", &L1h,&L2h,&N);
int i = 0,j =0,count = 0;
for(i = 0; i < N; i++ ){
scanf("%d", &j);
node[j].first = j;
scanf("%d%d",&node[j].Element,&node[j].Next);
//printf("j= %d\n,node[j].element = %d\n,[j].next = %d\n",j,node[j].Element,node[j].Next);
}
//L1 = BuildLink(L1h,node[]);//how to return two link
size1 = BuildNode(L1h,node,L1);
size2 = BuildNode(L2h,node,L2);
// printf("size1 = %d\n size2 = %d \n L1h= %d L2h = %d\n",size1,size2,L1h,L2h);

//L2R = Reverse(L2);
//L3 = Merge(L1,L2R);
if(size1>size2){
bigerSize = size1;
reverSize = size2 - 1;
print(bigerSize,reverSize,L1,L2);
}
else{
bigerSize = size2;
reverSize = size1 - 1;
print(bigerSize,reverSize,L2,L1);
}
return 0;
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
#include <stdio.h>
#include <stdlib.h>
typedef int ElementType;
typedef struct Node *PtrToNode;
typedef PtrToNode List;
typedef PtrToNode Position;
struct Node {
ElementType Element;
int first;
int Next;
};

int BuildNode(int Lh,struct Node node[],struct Node L1[]) {
int count = 0;
while(Lh != -1){
L1[count] = node[Lh];
printf("node[Lh] = %d , %d , %d \n",node[Lh].first,node[Lh].Element,node[Lh].Next);
Lh = node[Lh].Next;
count ++;
}
return count;
}

List Merge(List List1,List List2){
}

void print(int bigerSize,int reverSize,struct Node L1[],struct Node L2[]){
int i =1;
printf("%05d %d",L1[0].first,L1[0].Element);
for(i=1; i<bigerSize;i++){
printf(" %05d\n%05d %d", L1[i].first, L1[i].first, L1[i].Element);
if(i % 2 == 1 && reverSize >= 0){
printf(" %05d\n%05d %d", L2[reverSize].first, L2[reverSize].first, L2[reverSize].Element);
reverSize--;
}
}
printf(" -1");

}

int main(){
int L1h,L2h,N ,size1,size2,bigerSize,reverSize;
struct Node L1[100];
struct Node L2[100];
struct Node node[123456];
int addr[100],data[100],Next[100];
scanf("%d%d%d", &L1h,&L2h,&N);
int i = 0,j =0,count = 0;
for(i = 0; i < N; i++ ){
scanf("%d", &j);
node[j].first = j;
scanf("%d%d",&node[j].Element,&node[j].Next);
printf("j= %d\n,node[j].element = %d\n,[j].next = %d\n",j,node[j].Element,node[j].Next);
}
size1 = BuildNode(L1h,node,L1);
size2 = BuildNode(L2h,node,L2);
printf("size1 = %d\n size2 = %d \n L1h= %d L2h = %d\n",size1,size2,L1h,L2h);

if(size1>size2){
bigerSize = size1;
reverSize = size2 - 1;
print(bigerSize,reverSize,L1,L2);
}
else{
bigerSize = size2;
reverSize = size1 - 1;
print(bigerSize,reverSize,L2,L1);
}
return 0;
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
vector<int> S;
// 11分,有三个答案错误
int cmp1(int a, int b){
return a > b;
} // for non increasing sort

void init(int n) {
int i ;
for(i = 1; i <= n ;i++){
S[i] = -1 ; // 一开始,size都是1 ,没有根、
}
}

// if 根是他本身,那就直接返回。否则往上寻找根, path compression采用递归的方法。
int Find(int x){
if(S[x] <= -1) //如果是根那就返回
return x;
return S[x] = Find(S[x]);
}
// 如果根不相等那就合并, size小的连接到size大的。
void Union(int x1,int x2){
int root1,root2;
root1 = Find(x1); //先找到节点的根
root2 = Find(x2);
if( root1 == root2 )
return ; //root isn't equal then we merge them
if(S[root1] < S[root2]){
S[root1] += S[root2];
// cout << S[root1] << S[root2] ;
S[root2] = root1;
// cout << root1 ;
}
else{
S[root2] += S[root1];
// cout << S[root1] << S[root2] ;
S[root1] = root2;
}
}
/*0. 每个社交圈的结点号是人的编号,而不是课程。课程是用来判断是否处在一个社交圈的。
1. course[t]表示任意一个喜欢t活动的人的编号。如果当前的课程t,之前并没有人喜欢过,
那么就course[t] = i,i为喜欢course[t]当前人的编号
如果1号喜欢3号活动,那就course【3】 = 1;
2. course[t]是喜欢t活动的人的编号,
那么findFather(course[t])就是喜欢这个活动的人所处的社交圈子的根结点,
合并根结点和当前人的编号的结点i。即Union(i, findFather(course[t])),把它们处在同一个社交圈子里面
3. isRoot[i]表示编号i的人是不是它自己社交圈子的根结点,
如果等于0表示不是根结点,如果不等于0,每次标记isRoot[findFather(i)]++,那
么isRoot保存的就是如果当前是根结点,那么这个社交圈里面的总人数
4. isRoot中不为0的编号的个数cnt就是社交圈圈子的个数
最后遍历一遍看每个人是否
5. 把isRoot从大到小排列,输出前cnt个,就是社交圈人数的从大到小的输出顺序
*/
int main(void){
vector<int> isRoot;
int people,i,nob,j,tmphob;
char ch;
int course[1010] ={ 0 };// at most 1000 hobbies init
cin >> people;
S.resize(people+1);
init(people);
isRoot.resize(people+1);
for(i = 0; i < people;i ++){
cin >> nob;
cin >> ch ;
// cout << i << S[i] << nob << "开始新一行输出"<< endl ;
for(j = 0; j < nob ;j++){
cin >> tmphob;
// cout << i << S[i] << course[tmphob] ;
if(course[tmphob] == 0 ) {
course[tmphob] = i; // 记录喜欢course[t]当前人的编号
}
else{
//union this person and find[course[tmphob]]
Union(i,Find( course[tmphob] ) );
}
}
}
int count = 0,k = 0;
// 输出总共几个簇,然后每个簇多少人. 再遍历一遍每个人,看看他们分属于那个集合,并给相应集合的人数+1
for(i = 1; i <= people;i ++)
isRoot[Find(i)] ++;
for(i = 1; i <= people;i ++){
if(isRoot[i] != 0) //如果是根
count++;
}
cout << count <<endl;//iterator可以改元素值,但const_iterator不可改
sort(isRoot.begin(), isRoot.end(),cmp1);//默认升序,降序需要自己编写一个比较函数来实现,接着调用三个参数的sort:sort(begin,end,compare)就成了。
//对于list容器,这也可以. 或者用greater<data-type>()
cout << isRoot[k++] ;
while(isRoot[k]){
cout << ' '<< isRoot[k++] ;
}
}
3 changes: 3 additions & 0 deletions 数据结构基础/作业/dsHomework/.vs/ProjectSettings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"CurrentProjectSetting": "无配置"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"ExpandedNodes": [
""
],
"PreviewInSolutionExplorer": false
}
Binary file not shown.
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
#include <iostream>
using namespace std;
int S[10010];




// if 根是他本身,那就直接返回。否则往上寻找根, path compression采用递归的方法。
int Find(int x){
if(S[x] <= -1) //如果是根那就返回
return x;
return S[x] = Find(S[x]);
}
//
// 如果根不相等那就合并, size小的连接到size大的。
void Union(int x1,int x2){
int root1,root2;
root1 = Find(x1); //先找到节点的根
root2 = Find(x2);
if( root1 == root2 )
return ; //root isn't equal then we merge them
if(S[root1] < S[root2]){
S[root1] += S[root2];
// cout << S[root1] << S[root2] ;
S[root2] = root1;
// cout << root1 ;
}
else{
S[root2] += S[root1];
// cout << S[root1] << S[root2] ;
S[root1] = root2;
}
}

int main(void){
int n,i,c1=0,c2=0 ;
char op;
cin >> n;
for(i = 1; i <= n ;i++){
S[i] = -1 ; // 一开始,size都是1 ,没有根、
}
for(i = 1 ;i <= n; i++)
{
// printf("%d ",S[i]);
}
cin >> op ;
while(op != 'S'){
cin >> c1 >> c2 ;
// printf("this line %d%d\n",c1,c2);
if(op == 'I'){
// cout << "union begin";
Union(c1,c2);
}
else{
if( Find(c1) == Find(c2) )
cout << "yes" << endl;
else
cout << "no" << endl;
}
// cout << "thisline finded" << endl;
cin >> op;
}
int count = 0 ;
for(i = 1;i<= n;i++){
if(Find(i) == i){
count++;
}
}
if(count == 1)
cout << "The network is connected." << endl;
else
cout << "There are "<< count <<" components." << endl;
}
Loading

0 comments on commit 6246b32

Please sign in to comment.