Compare commits

...

No commits in common. 'master' and 'dev_test3' have entirely different histories.

8
.idea/.gitignore vendored

@ -1,8 +0,0 @@
# Default ignored files
/shelf/
/workspace.xml
# Datasource local storage ignored files
/../../../../../:\PyCharm\文件\疫情数据分析\.idea/dataSources/
/dataSources.local.xml
# 基于编辑器的 HTTP 客户端请求
/httpRequests/

@ -1,6 +0,0 @@
<component name="InspectionProjectProfileManager">
<settings>
<option name="USE_PROJECT_PROFILE" value="false" />
<version value="1.0" />
</settings>
</component>

@ -1,4 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.7 (base)" project-jdk-type="Python SDK" />
</project>

@ -1,8 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/.idea/疫情数据分析.iml" filepath="$PROJECT_DIR$/.idea/疫情数据分析.iml" />
</modules>
</component>
</project>

@ -1,8 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="PYTHON_MODULE" version="4">
<component name="NewModuleRootManager">
<content url="file://$MODULE_DIR$" />
<orderEntry type="jdk" jdkName="Python 3.7 (base)" jdkType="Python SDK" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>

Binary file not shown.

Binary file not shown.

@ -0,0 +1,3 @@
{
"CurrentProjectSetting": "无配置"
}

@ -0,0 +1,6 @@
{
"ExpandedNodes": [
""
],
"PreviewInSolutionExplorer": false
}

Binary file not shown.

@ -1,105 +0,0 @@
#include<stdio.h>
#include<stdlib.h>
typedef struct AVLNode* AVLTree;
struct AVLNode { //AVL树的结构左子树右子树高度数据
AVLTree Left;
AVLTree Right;
int Height;
int Data;
};
int Max(int a, int b) {
return a > b ? a : b;
}
int GetHeight(AVLTree T) { //递归计算树的高度
int HL, HR;
if (T) {
HL = GetHeight(T->Left);
HR = GetHeight(T->Right);
return Max(HL, HR) + 1;
}
else
return 0;
}
AVLTree SingleLeftRotation(AVLTree A) {
AVLTree B = A->Left;
A->Left = B->Right;
B->Right = A;
A->Height = GetHeight(A);
B->Height = GetHeight(B);
return B;
}
AVLTree SingleRightRotation(AVLTree A) {
AVLTree B = A->Right;
A->Right = B->Left;
B->Left = A;
A->Height = GetHeight(A);
B->Height = GetHeight(B);
return B;
}
AVLTree DoubleLeftRightRotation(AVLTree A) {
A->Left = SingleRightRotation(A->Left);
return SingleLeftRotation(A);
}
AVLTree DoubleRightLeftRotation(AVLTree A) {
A->Right = SingleLeftRotation(A->Right);
return SingleRightRotation(A);
}
AVLTree Insert(AVLTree T, int x) {
if (!T) {
T = (AVLTree)malloc(sizeof(struct AVLNode));
T->Data = x;
T->Left = NULL;
T->Right = NULL;
T->Height = 1;
}
else if (x < T->Data) {
T->Left = Insert(T->Left, x);
if (GetHeight(T->Left) - GetHeight(T->Right) == 2) { //注意这里还没更新树高不能用T->Left->Height之类
if (x < T->Data)
T = SingleLeftRotation(T);
else if (x > T->Data)
T = DoubleLeftRightRotation(T);
}
}
else if (x > T->Data) {
T->Right=Insert(T->Right, x);
if (GetHeight(T->Left) - GetHeight(T->Right) == -2)
if (x > T->Right->Data)
T = SingleRightRotation(T);
else
T = DoubleRightLeftRotation(T);
}
T->Height = GetHeight(T);
return T;
}
void PreorderTravelsal(AVLTree BT) {
if (BT) {
printf("%d ", BT->Data);
PreorderTravelsal(BT->Left);
PreorderTravelsal(BT->Right);
}
}
int main(void) {
int n,number, i;
AVLTree T = NULL;
scanf_s("%d", &n);
for (i = 0; i < n; i++) {
scanf_s("%d", &number);
T=Insert(T, number);
PreorderTravelsal(T);
printf("\n");
}
return 0;
}

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

@ -1,2 +1,2 @@
#TargetFrameworkVersion=v4.0:PlatformToolSet=v142:EnableManagedIncrementalBuild=false:VCToolArchitecture=Native32Bit:WindowsTargetPlatformVersion=10.0
Debug|Win32|C:\Users\13251\source\repos\AVL树\|
Debug|Win32|C:\Visual Studio\Dijkstra算法\|

Binary file not shown.

Binary file not shown.

@ -0,0 +1,131 @@
#include<stdio.h>
#include<stdlib.h>
#define MaxNv 100
#define INFINITY 65535
#define False -1
#define True 1
#define ERROR -1
struct GNode { //图的结构
int Ne;
int Nv;
int G[MaxNv][MaxNv];
};
typedef struct GNode* MGraph;
MGraph CreateGraph(int NvNum) { //初始化图
int i, j;
MGraph Graph = (MGraph)malloc(sizeof(struct GNode));
Graph->Nv = NvNum;
Graph->Ne = 0;
for (i = 0; i < Graph->Nv; i++)
for (j = 0; j < Graph->Nv; j++) {
Graph->G[i][j] = INFINITY;
}
return Graph;
}
MGraph InsertEdge(MGraph Graph, int V1, int V2,int Weight) { //插入边
Graph->G[V1][V2] = Graph->G[V2][V1] = Weight;
return Graph;
}
MGraph BuildGraph() { //建图函数
int NvNum, NeNum,Weight;
int i;
scanf_s("%d", &NvNum);
MGraph Graph = CreateGraph(NvNum);
scanf_s("%d", &NeNum);
Graph->Ne = NeNum;
int V1, V2;
for (i = 0; i < Graph->Ne; i++) {
scanf_s("%d%d%d", &V1, &V2, &Weight);
InsertEdge(Graph, V1, V2, Weight);
}
return Graph;
}
int FindMin(MGraph Graph, int dist[], int collected[]) { //寻找未被收录且dist最小的点的下标
int i, min = INFINITY, vertex;
for (i = 0; i < Graph->Nv; i++) {
if (collected[i]==False&&dist[i] < min) {
min = dist[i];
vertex = i;
}
}
if (min < INFINITY)
return vertex;
else
return ERROR;
}
bool Dijkstra(MGraph Graph, int dist[], int path[], int s) {
int v, w;
int collected[MaxNv];
for (v = 0; v < Graph->Nv; v++) {
dist[v] = Graph->G[s][v]; //初始化所有点的dist为该点到起始点的权值
//初始化所有点的path
if (Graph->G[s][v] < INFINITY) //若与起点之间有边
path[v] = s; //则path为起始点下标表示父节点
else //若与起始点之间没有边
path[v] = -1; //则path为-1表示没有父节点
collected[v] = False; //初始化所有点都未被收录
}
collected[s] = True; //将起始点收录
dist[s] = 0; //初始化时为INFINITY这里再初始化为0
while (1) { //开始算法循环
v = FindMin(Graph, dist, collected); //在未收录的点里面找dist最小的
if (v == ERROR) //该连通分支找完返回ERROR
break;
collected[v] = True; //收录该点
for (w = 0; w < Graph->Nv; w++) { //对于所有点
if (dist[v] + Graph->G[v][w] < dist[w]) { //若点v的收录可使其他点dist减小
dist[w] = dist[v] + Graph->G[v][w]; //则更新dist
path[w] = v;
}
}
}
return true;
}
int main(void) {
int dist[MaxNv], path[MaxNv], tmp[MaxNv];
int i = 1, v, j;
MGraph Graph = BuildGraph();
Dijkstra(Graph, dist, path, 0);
scanf_s("%d", &v);
tmp[0] = v;
while (1) { //逆序输出路径
v = path[v];
tmp[i] = v;
i++;
if (path[v] == -1)
break;
}
for (j = i-1; j >=0; j--) {
printf("%d ", tmp[j]);
}
return 0;
}
/*
10
17
0 1 2
0 3 5
1 2 5
1 3 2
2 4 8
2 5 4
3 5 4
3 6 2
4 5 2
6 5 3
4 7 5
5 7 9
5 8 6
6 8 7
7 8 3
7 9 4
8 9 8
P236
*/

@ -3,7 +3,7 @@ Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.29411.108
MinimumVisualStudioVersion = 10.0.40219.1
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "AVL树", "AVL树.vcxproj", "{508852FE-4295-442A-9E1C-94351356E239}"
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Dijkstra算法", "Dijkstra算法.vcxproj", "{71EEE3DE-0E49-4176-BF1C-4AA4B772A14C}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@ -13,19 +13,19 @@ Global
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{508852FE-4295-442A-9E1C-94351356E239}.Debug|x64.ActiveCfg = Debug|x64
{508852FE-4295-442A-9E1C-94351356E239}.Debug|x64.Build.0 = Debug|x64
{508852FE-4295-442A-9E1C-94351356E239}.Debug|x86.ActiveCfg = Debug|Win32
{508852FE-4295-442A-9E1C-94351356E239}.Debug|x86.Build.0 = Debug|Win32
{508852FE-4295-442A-9E1C-94351356E239}.Release|x64.ActiveCfg = Release|x64
{508852FE-4295-442A-9E1C-94351356E239}.Release|x64.Build.0 = Release|x64
{508852FE-4295-442A-9E1C-94351356E239}.Release|x86.ActiveCfg = Release|Win32
{508852FE-4295-442A-9E1C-94351356E239}.Release|x86.Build.0 = Release|Win32
{71EEE3DE-0E49-4176-BF1C-4AA4B772A14C}.Debug|x64.ActiveCfg = Debug|x64
{71EEE3DE-0E49-4176-BF1C-4AA4B772A14C}.Debug|x64.Build.0 = Debug|x64
{71EEE3DE-0E49-4176-BF1C-4AA4B772A14C}.Debug|x86.ActiveCfg = Debug|Win32
{71EEE3DE-0E49-4176-BF1C-4AA4B772A14C}.Debug|x86.Build.0 = Debug|Win32
{71EEE3DE-0E49-4176-BF1C-4AA4B772A14C}.Release|x64.ActiveCfg = Release|x64
{71EEE3DE-0E49-4176-BF1C-4AA4B772A14C}.Release|x64.Build.0 = Release|x64
{71EEE3DE-0E49-4176-BF1C-4AA4B772A14C}.Release|x86.ActiveCfg = Release|Win32
{71EEE3DE-0E49-4176-BF1C-4AA4B772A14C}.Release|x86.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {0A702C47-D3D6-4610-96F7-A6A711E54015}
SolutionGuid = {7E610167-7014-420F-AFC1-83B141C181B3}
EndGlobalSection
EndGlobal

@ -20,9 +20,9 @@
</ItemGroup>
<PropertyGroup Label="Globals">
<VCProjectVersion>16.0</VCProjectVersion>
<ProjectGuid>{508852FE-4295-442A-9E1C-94351356E239}</ProjectGuid>
<ProjectGuid>{71EEE3DE-0E49-4176-BF1C-4AA4B772A14C}</ProjectGuid>
<Keyword>Win32Proj</Keyword>
<RootNamespace>AVL树</RootNamespace>
<RootNamespace>Dijkstra算法</RootNamespace>
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
@ -151,7 +151,7 @@
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="AVL树.cpp" />
<ClCompile Include="Dijkstra算法.cpp" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">

@ -15,7 +15,7 @@
</Filter>
</ItemGroup>
<ItemGroup>
<ClCompile Include="AVL树.cpp">
<ClCompile Include="Dijkstra算法.cpp">
<Filter>源文件</Filter>
</ClCompile>
</ItemGroup>

@ -1,11 +0,0 @@
Stack trace:
Frame Function Args
00800000010 0018006392E (00180279F10, 0018026AFD1, 00800000010, 000FFFFBA00)
00800000010 0018004973A (00100002000, 000FFFFCBA0, 00180350090, 00000000002)
00800000010 00180049772 (00000000002, 001803503A0, 00800000010, 00000000008)
00800000010 0018005CBDD (000FFFFCC94, 000FFFFCBD0, 000FFFFCC68, 000FFFFCC94)
000FFFFCBAC 0018005CD4F (675C645C625C2F5C, 655C2E5C745C695C, 6F5C635C755C645C, 2E5C725C655C645C)
000FFFFCCE0 00180049EE8 (00000000000, 00000000000, 00000000000, 00000000000)
000FFFFFFF0 00180048846 (00000000000, 00000000000, 00000000000, 00000000000)
000FFFFFFF0 001800488F4 (00000000000, 00000000000, 00000000000, 00000000000)
End of stack trace

@ -1,25 +0,0 @@
class summaryDataOut:
confirmed=0
died=0
curConfirm=0
cured=0
confirmedRelative=0
curedRelative=0
diedRelative=0
curConfirmRelative=0
relativeTime=0
time=''
def blankNum (self,object):
return ' '*(12-len(str(object)))
def PrintOut(self):
print("截至%s国外疫情概况:"%self.time)
print("现有确诊:%d" % self.curConfirm, end=self.blankNum(self.curConfirm))
print("相对昨日新增:%d"%self.curConfirmRelative)
print("累计确诊:%d"%self.confirmed,end=self.blankNum(self.confirmed))
print("相对昨日新增:%d"%self.confirmedRelative)
print("累计治愈:%d"%self.cured,end=self.blankNum(self.cured))
print("相对昨日新增:%d"%self.curedRelative)
print("累计死亡:%d"%self.died,end=self.blankNum(self.died))
print("相对昨日新增:%d"%self.diedRelative)

@ -1,34 +0,0 @@
import requests
import re
from bs4 import BeautifulSoup
import json
from 国外总数据 import summaryDataOut
# 获取数据
req = requests.get ('https://voice.baidu.com/act/newpneumonia/newpneumonia/?from=osari_pc_3#tab4')
content = req.content.decode('utf-8')
soup = BeautifulSoup(content,'html.parser')
# 过滤筛选
tag = soup.find('script',attrs={'type':'application/json','id':'captain-config'})
tagstr=tag.string #标签转化为字符串
tagdic=json.loads(tagstr) #标签字符串转化为字典
component=tagdic['component'][0]
time= component['mapLastUpdatedTime']
result = component['summaryDataOut'] #字典中找出'component'key下的'summaryDataOut'key内容
# 存储
OutData=summaryDataOut()
OutData.confirmed=int(result['confirmed'])
OutData.confirmedRelative=int(result['confirmedRelative'])
OutData.cured=int(result['cured'])
OutData.curedRelative=int(result['curedRelative'])
OutData.died=int(result['died'])
OutData.diedRelative=int(result['diedRelative'])
OutData.curConfirm=int(result['curConfirm'])
OutData.curConfirmRelative=int(result['curConfirmRelative'])
OutData.time=time
OutData.PrintOut()

Binary file not shown.
Loading…
Cancel
Save