自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(55)
  • 收藏
  • 关注

原创 PTA 7-15 PAT Judge (25 分)

#include <bits/stdc++.h>using namespace std;typedef struct{ int id, flag = 0, cnt = 0, sum = 0; vector<int> marks;}stu;//int cmp(stu a, stu b);int cmp(int a, int b);vector<stu&g...

2019-03-06 21:58:54 371

原创 PTA 7-11 关键活动 (30 分)

#include <bits/stdc++.h>#define mem(a, b) memset(a, b, sizeof a)#define INF 0x3f3f3f3fusing namespace std;const int maxn = 200;int n, m, rs, ans;int dfn[maxn][maxn], dis[maxn][maxn];i...

2019-02-27 19:58:18 1478

原创 中国大学MOOC-陈越、何钦铭-数据结构-2018秋 07-图6 旅游规划 (25 分)

#include <bits/stdc++.h>#define INFINITY 65535using namespace std;const int maxnum = 500;int dist[maxnum], cost[maxnum], Edge[maxnum][maxnum], Cost[maxnum][maxnum], collected[maxnum];int...

2019-01-06 02:05:58 335

原创 Data Structures and Algorithms (English) 7-11 Saving James Bond - Hard Version (30 分)

#include <bits/stdc++.h>using namespace std;#define INFINITY 65535 /*无穷大设为双字节无符号整数的最大值*/ #define MAXNUMBER 100 /*鳄鱼最大数设为100*/#define RADIUS 50 /*湖的半径*/#define ISLAND 7.5 /*岛的半径*/ struct...

2019-01-05 20:56:44 381

原创 中国大学MOOC-陈越、何钦铭-数据结构-2018秋 07-图4 哈利·波特的考试 (25 分)

#include <bits/stdc++.h>using namespace std;#define MaxVertexNum 100 /*最大顶点数设为100*/#define INFINITY 65535 /*无穷大设为双字节无符号整数的最大值*/ typedef int Vertex; /*顶点下标为整型,用来表示顶点*/ typedef int WeightT...

2019-01-02 00:45:19 425

原创 中国大学MOOC-陈越、何钦铭-数据结构-2018秋 06-图3 六度空间 (30 分)

#include <bits/stdc++.h>using namespace std;const int BORDER = 50;const double ISLAND = 15.0/2;const int N = 100;typedef struct node{ double x, y;}node; node position[N];int visited...

2018-12-24 19:03:14 246

原创 中国大学MOOC-陈越、何钦铭-数据结构-2018秋 06-图1 列出连通集 (25 分)

#include <bits/stdc++.h>using namespace std; int Graph[10][10];int N,E;int visited[10]; void DFS(int node);void BFS(int node); int main(){ #ifdef ONLINE_JUDGE #else freopen("in.tx...

2018-12-24 00:02:41 293

原创 https://www.icourse163.org/learn/PKU-1002534001?tid=1003136008#/learn/quiz?id=1003986014

对于以下等价类,采用“加权合并规则”(也称“重量权衡合并规则”),进行并查运算,给出最后父节点索引序列。For the following equivalence class, please use “weighted union rule” and UNION/FIND algorithm to write down the final parent node index sequence. 4...

2018-12-20 19:34:11 26659 3

原创 中国大学MOOC-陈越、何钦铭-数据结构-2018秋 05-树8 File Transfer (25 分)

#include <bits/stdc++.h>using namespace std;int numbers[10001], m, n;set <int> s;int FindRoot(int index);void Connection(int index1, int index2);int main(){ #ifdef ONLINE_JUDGE...

2018-12-17 21:08:00 235

原创 中国大学MOOC-陈越、何钦铭-数据结构-2018秋 05-树7 堆中的路径 (25 分)

#include <bits/stdc++.h>#define MAX 1001#define MINH -10001int Heap[MAX], size;void Creat();void Insert(int value);using namespace std;int main(){ int N, M, tmp, j; cin >> N...

2018-12-16 18:46:23 291

原创 中国大学MOOC-陈越、何钦铭-数据结构-2018秋 04-树5 Root of AVL Tree (25 分)

#include "pch.h"#include <iostream>#include <algorithm>#include <vector>using namespace std;class Node {public: int data; Node* left; Node* right;};Node* NewNode(int val...

2018-12-15 18:25:21 200

原创 中国大学MOOC-陈越、何钦铭-数据结构-2018秋 04-树4 是否同一棵二叉搜索树 (25 分)

#include "pch.h"#include <iostream>using namespace std;typedef class TreeNode * Tree;class TreeNode {public: int value; Tree left, right; int flag;};Tree MakeTree(int N);Tree Inser...

2018-12-14 21:49:16 268

原创 中国大学MOOC-陈越、何钦铭-数据结构-2018秋 03-树3 Tree Traversals Again (25 分)

#include "pch.h"#include <iostream>#include <string>#include <stack>using namespace std;int preorder[35], inorder[35];int pre_index = 0, in_index = 0, N, cnt = 0;int get()...

2018-12-14 00:59:48 296

原创 中国大学MOOC-陈越、何钦铭-数据结构-2018秋 03-树2 List Leaves (25 分)

#include "pch.h"#include <iostream>#include <queue>#define MAX 10using namespace std;class Node {public: int index; int lchild; int rchild;};Node node[MAX];int isRoot[MAX] ...

2018-12-13 22:37:57 221

原创 PTA数据结构与算法题目集(中文)7-3 树的同构 (25 分)

#include <cstdlib>#include <iostream>#include <cstring>#include <cstdio>using namespace std;#define MaxTree 10#define ElementType char#define Tree int#define Null -1...

2018-12-13 19:32:31 444

原创 PTA习题9-5 通讯录排序(20 分)

#include<stdio.h>#include<stdlib.h>#include<string.h>typedef struct { char name[11]; int birth; char phone[18];}friends;int main(){ friends *p,t; int n...

2018-09-05 19:28:53 7584

原创 PTA习题9-4 查找书籍(20 分)

#include<stdio.h>#include<stdlib.h>typedef struct book{ char mame[31]; double price;}book;int main(){ int n,min=0,max=0,i; book *p; scanf("%d",&n); g...

2018-09-04 20:42:06 6124

原创 PTA习题9-3 平面向量加法(15 分)********

#include<stdio.h>#include<math.h>#define EP 0.05typedef struct vector{ double x; double y;}vector;int main(){ vector v1,v2,v; scanf("%lf%lf%lf%lf",&v1.x,&a...

2018-09-04 19:06:08 1392 1

原创 PTA习题9-1 时间换算(15 分)

#include<stdio.h>typedef struct time{ int hour; int minute; int second;}time;int main(){ time a; int n; scanf("%d:%d:%d",&a.hour,&a.minute,&...

2018-09-04 16:56:22 5246

原创 PTA习题7-8 字符串转换成十进制整数(15 分)

#include<stdio.h>int main(){ char a; int flag=1,mark=0,sum=0;//flag来表示有没有读到第一个字符,mark来表示第一个字符是不是'-' scanf("%c",&a); while(a!='#'){ if(a>='0'&&a<=...

2018-09-03 19:57:18 10097 4

原创 习题7-7 字符串替换(15 分)

#include<stdio.h>#include<string.h>#define MAXN 80int main(){ int i; char str[MAXN]; gets(str); for(i=0;str[i]!='\0';i++){ if(str[i]>='A'&&str[i...

2018-09-02 22:31:55 2406

原创 PTA习题7-6 统计大写辅音字母(15 分)

#include<string.h>#include<stdio.h>#define MAXN 80int main(){ int i,len,cnt1=0,cnt2=0;//cnt1记录大写字母总数,cnt2记录大写辅音字母总数 char str[MAXN]; gets(str); len=strlen(str); ...

2018-09-02 21:52:22 7215 2

原创 PTA习题7-5 找鞍点(20 分)

#include<stdio.h>int main(){ int n,i,j,p=0,y,flag=0;//p是一行里面最大的列下标 ,y是当前的行下标 scanf("%d",&n); int a[n][n]; for(i=0;i<n;i++){ for(j=0;j<n;j++){ ...

2018-09-02 20:21:46 3158 1

原创 PTA习题7-4 求矩阵各行元素之和(15 分)

#include<stdio.h>int main(){ int m,n,i,j; scanf("%d%d",&m,&n); int a[m][n],sum[m]={0}; for(i=0;i<m;i++){ for(j=0;j<n;j++){ scanf("%d",&am...

2018-09-02 18:57:31 7453 2

原创 PTA习题7-3 判断上三角矩阵(15 分)

#include<stdio.h>int main(){ int T,N,i,j,flag; scanf("%d",&T); while(T--){ scanf("%d",&N); int a[N][N]; for(i=0;i<N;i++){ for(j...

2018-09-02 17:41:55 7464 3

原创 PTA习题7-2 求一批整数中出现最多的个位数字(20 分)

#include<stdio.h>int main(){ int N,i,number,max=0,a[10]={0}; scanf("%d",&N); for(i=0;i<N;i++){ scanf("%d",&number); while(number>0){ ...

2018-09-02 16:20:41 6331

原创 PTA习题7-1 选择法排序(20 分)

#include<stdio.h>#define MAXN 10int main(){ int i,j,index,N,tmp; scanf("%d",&N); int a[N]; for(i=0;i<N;i++){ scanf("%d",&a[i]); } for(i=0;i<...

2018-09-02 15:38:46 11981

原创 PTA练习7-11 字符串逆序(15 分)

#include<stdio.h>#include<string.h>#define MAXN 80int main(){ char str[MAXN]; int len,i; gets(str); len=strlen(str); for(i=len-1;i>=0;i--){ printf("...

2018-09-02 15:06:53 2866 1

原创 PTA练习7-10 查找指定字符(15 分)

#include<stdio.h>#define MAXN 80int main(){ int i,len=0,index=-1; char a,ch,str[MAXN]; scanf("%c\n",&a); ch=getchar(); for(i=0;ch!='\n';i++){ str[i]=ch; ...

2018-09-02 14:39:48 7766

原创 PTA练习7-9 计算天数(15 分)

#include<stdio.h>int main(){ int year,month,day,days=0,i; scanf("%d/%d/%d",&year,&month,&day); int months[12]={31,28,31,30,31,30,31,31,30,31,30,31}; if((year%4==...

2018-09-02 13:58:22 2168 1

原创 PTA练习7-8 方阵循环右移(20 分)

#include<stdio.h>int main(){ int m,n; scanf("%d%d",&m,&n); int a[n][n]; int i,j; for(i=0;i<n;i++){ for(j=0;j<n;j++){ scanf("%d",&...

2018-09-01 22:46:59 4558 1

原创 PTA练习7-7 矩阵运算(20 分)

#include<stdio.h>int main(){ int N,i,j,sum=0; scanf("%d",&N); int M[N][N]; for(i=0;i<N;i++){ for(j=0;j<N;j++){ scanf("%d",&M[i][j]); ...

2018-09-01 20:34:27 3729

原创 练习7-3 将数组中的数逆序存放(20 分)

#include<stdio.h>int main(){ int i,j,N; scanf("%d",&N); int a[N],b[N]; for(i=0;i<N;i++){ scanf("%d",&a[i]); } for(j=N-1,i=0;j>=0;j--,i++){...

2018-09-01 15:39:08 3916

原创 PTA练习7-2 求最大值及其下标(20 分)

#include<stdio.h>int main(){ int index=0,i,N; scanf("%d",&N); int a[N]; for(i=0;i<N;i++){ scanf("%d",&a[i]); } for(i=1;i<N;i++){ ...

2018-09-01 15:20:38 2732

原创 PTA习题6-7 简单计算器(20 分)

#include<stdio.h>int main(){ int num,sum,error=0; char op='0'; scanf("%d",&sum); scanf("%c",&op); do{ if(op=='=') break; scanf("%d",&num)...

2018-08-31 19:22:12 6333 1

原创 习题4-11 兔子繁衍问题(15 分)

#include<stdio.h>int main(){ int N,sum=1,now=0,increase=0,month=1; scanf("%d",&N); if(sum==N) printf("%d",month); else{ month++; now=sum+increase; ...

2018-08-31 17:36:41 1304

原创 PTA习题4-10 猴子吃桃问题(15 分)

#include<stdio.h>int main(){ int N,i,num=1; scanf("%d",&N); for(i=1;i<=N-1;i++){ num=(num+1)*2; } printf("%d",num); return 0;}

2018-08-31 16:56:37 2356

原创 习题4-9 打印菱形图案(15 分)

#include<stdio.h>int main(){ int n,row,i,j; scanf("%d",&n); row=n/2+1; for(i=1;i<=row;i++){ for(j=1;j<=row-i;j++){ printf(" "); }...

2018-08-31 16:48:32 797

原创 习题4-8 高空坠球(20 分)

#include<stdio.h>#include<math.h>int main(){ int height,n; double dis=0,heightN; int i; scanf("%d%d",&height,&n); heightN=height; for(i=1;i<=n;i+...

2018-08-30 22:16:50 1849

原创 PTA习题4-7 最大公约数和最小公倍数(15 分)

#include<stdio.h>int main(){ int m,n,a,b,c;//m,n用来接收两个整数,a、b作为两数的副本,c作为余数; scanf("%d%d",&m,&n); if(m<n){ //让m>n c=m; m=n; n=c; ...

2018-08-30 21:49:59 3346

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除