- 博客(66)
- 资源 (57)
- 收藏
- 关注
原创 哈工大python期末考试编程1
def get_standard_str(s): lis = list(s) lis.sort() s = "".join(lis) return sstop_word = ""dict1 = {}for line in iter(input, stop_word): standard_str = get_standard_str(line) ...
2019-06-01 21:07:48
2431
原创 POJ 2488
#include <bits/stdc++.h>using namespace std;int visited[30][30];struct Pos{ int r, c;};Pos path[30];Pos mov[8] = {{-2, -1}, {-2, 1}, {-1, -2}, {-1, 2}, {1, -2}, {1, 2}, {2, -1}, {2, ...
2019-03-23 18:49:23
446
原创 POJ 2816:红与黑
#include <bits/stdc++.h>using namespace std;char maze[25][25];int visited[25][25];int area = 0;int W, H;int sr, sc;void DFS(int r, int c);int main(){ while(true){// cin >> W &g...
2019-03-22 23:36:20
361
原创 POJ 4115:鸣人和佐助
#include <bits/stdc++.h>using namespace std;int M, N, T;char m[210][210];int used[210][210][15];struct Pos{ int r, c, ck, steps; Pos(int rr, int cc, int cck, int ss):r(rr), c(cc), ck(cc...
2019-03-22 20:09:38
535
原创 POJ 3151:Pots
#include <bits/stdc++.h>using namespace std;int A, B, C;struct Status{ int a, b; int prev; int mov; //用来定义operation int src, dest; }; Status que[11000];int head = 0, tail = 1;int flag...
2019-03-22 15:20:09
338
原创 百练 4127:迷宫问题
#include <bits/stdc++.h>using namespace std;struct Pos{ int r, c; int f; Pos(int rr = 0, int cc = 0, int ff = 0) : r(rr), c(cc), f(ff){}};const int maxLofMaze = 8;const int maxLofqueue =...
2019-03-20 21:32:53
808
原创 百练1328:Radar Installation
#include <bits/stdc++.h>using namespace std;const double eps = 1e-6;int n, d;struct Seg{ double x1, x2; bool operator < (const Seg & s) const { return x1 - s.x1 < -eps; }};...
2019-03-20 14:15:11
316
原创 百练1042:Gone Fishing
#include <bits/stdc++.h>using namespace std;const int maxL = 30;int f[maxL];int d[maxL];int t[maxL];int maxFishes = -1; int lakeTime[maxL];int bestLakeTime[maxL];struct Lake{ int No; ...
2019-03-19 22:32:33
558
原创 程序设计实习MOOC / 程序设计与算法(二)测验汇总(2019春季) 002:拨钟问题
#include <iostream>#include <bitset>#include <algorithm>#include <functional>#include <cstring>#include <bits/stdc++.h>using namespace std;int oriClocks[9];...
2019-03-18 19:23:20
874
原创 程序设计实习MOOC / 程序设计与算法(二)测验汇总(2019春季) 017
#include <bits/stdc++.h>using namespace std;const int N = 20 + 1, INF = 0x3f3f3f3f;int f[N][N][N], w, h, m;void solve();int main(){ while(scanf("%d%d%d", &w, &h, &m) != EOF){...
2019-03-17 11:31:49
616
原创 程序设计实习MOOC / 程序设计与算法(二)测验汇总(2019春季) 016
#include <bits/stdc++.h>using namespace std;int w[3402 + 1], v[3402 + 1]; //w用来记录每个Bracelet的重量,v用来记录每个Bracelet的价值int dp[12880 + 1]; //dp用来记录每个背包的最大载重量 int main(){ int N, M; scanf("%d%d", ...
2019-03-17 09:27:32
486
原创 程序设计实习MOOC的程序设计与算法(二)测验汇总(2019春季) 013Zipper
#include <bits/stdc++.h>using namespace std;const int maxn = 2 * 1e2 + 1 ;int dp[maxn][maxn];int main(){ #ifdef ONLINE_JUDGE #else freopen("in.txt", "r", stdin); #endif int N; scanf...
2019-03-16 11:56:40
561
原创 程序设计实习MOOC / 程序设计与算法(二)测验汇总(2019春季) 012 拦截导弹
#include <bits/stdc++.h>using namespace std;int main(){ int k; scanf("%d", &k); int key = 1; vector<int> d(k, 0); vector<int> dp(k, 1); int i, j; for(i = 0; i < k; i...
2019-03-15 14:44:01
367
原创 2018 第九届蓝桥杯省赛总结 + 解题报告(C语言B组)3.乘积尾零
#include <bits/stdc++.h>using namespace std;int main(){ #ifdef ONLINE_JUDGE #else freopen("in.txt", "r", stdin); #endif int c2 = 0, c5 = 0; int N; int i; for(i = 0; i < 100; i+...
2019-03-14 01:04:32
263
原创 2018 第九届蓝桥杯省赛总结 + 解题报告(C语言B组)2.明码
#include <bits/stdc++.h>using namespace std;string foo(int n);int main(){ #ifdef ONLINE_JUDGE #else freopen("in.txt", "r", stdin); #endif int a[10][32]; int i, j; for(i = 0; i < ...
2019-03-14 00:53:39
370
原创 PTA KMP 串的模式匹配 (25 分)
#include <bits/stdc++.h>using namespace std;typedef int Pos;#define NotFound -1void BuildMatch(char *pattern, int *match);Pos KMP(char *str, char *pattern);int main(){ #ifdef ONLINE_JU...
2019-03-10 18:48:46
3232
原创 PTA 7-15 QQ帐户的申请与登陆 (25 分)
#include <bits/stdc++.h>using namespace std;map<string, string> M;int main(){ #ifdef ONLINE_JUDGE #else freopen("in.txt", "r", stdin); #endif int N; scanf("%d", &N); char ...
2019-03-09 00:10:12
1068
原创 PTA 11-散列2 Hashing (25 分)
#include <bits/stdc++.h>using namespace std;bool isPrime(int n);int main(){ #ifdef ONLINE_JUDGE #else freopen("in.txt", "r", stdin); #endif int Max, N; //Max用来存储哈希表的长度 scanf("%d%d", ...
2019-03-08 21:18:36
521
原创 PTA 7-14 电话聊天狂人 (25 分)
#include <bits/stdc++.h>using namespace std;map<long long, int> p;int main(){ #ifdef ONLINE_JUDGE #else freopen("in.txt", "r", stdin); #endif int N; scanf("%d", &N); int i...
2019-03-08 19:45:40
971
原创 PTA 7-16 Sort with Swap(0, i) (25 分)
#include <bits/stdc++.h>using namespace std;struct Elem{ bool isSelec = false; int data;};int ElemCntinEachCircle(Elem* A, int pos);int main(){ #ifdef ONLINE_JUDGE #else freopen("in.t...
2019-03-07 01:03:36
523
原创 PTA 7-13 统计工龄 (20 分)
#include <bits/stdc++.h>using namespace std;int main(){ #ifdef ONLINE_JUDGE #else freopen("in.txt", "r", stdin); #endif int N, key; cin >> N; map<int, int> M; int i; fo...
2019-03-06 14:48:44
727
原创 PTA 09-排序3 Insertion or Heap Sort (25 分)
#include <bits/stdc++.h>using namespace std;int main(){ #ifdef ONLINE_JUDGE #else freopen("in.txt", "r", stdin); #endif int N; cin >> N; int A[N], B[N]; int i, j; int cnt;...
2019-03-06 14:38:59
379
原创 PTA 09-排序2 Insert or Merge (25 分)
#include <bits/stdc++.h>using namespace std;int main(){ #ifdef ONLINE_JUDGE #else freopen("in.txt", "r", stdin); #endif int N; cin >> N; int v1[N], v2[N]; int i, j; int len...
2019-03-05 22:12:58
474
原创 PTA 7-12 How Long Does It Take (25 分)
#include <bits/stdc++.h>using namespace std;const int maxn = 100;int mapn[maxn][maxn], dis[maxn];int in[maxn];int n, m;int toposort();int main(){ #ifdef ONLINE_JUDGE #else freope...
2019-02-26 18:53:56
512
原创 PTA 7-10 公路村村通 (30 分)
#include <bits/stdc++.h>using namespace std;const int inf = 999999;int n, m; //N为城镇数目,M为候选道路数目int g[1000][1000]; //g[][]用来存储城镇之间的距离int x, y, z; //初始化时x,y用作一条路径两端的城镇,z用作路径的长度 int cost[10...
2019-02-26 17:29:10
964
原创 12.编写程序,其功能是从键盘输入n*n个整型数(n≤20),组成n行n列数组,打印出其上三角数组。
#include <stdio.h>int main(){ int Matrix[20][20]; int size; int i, j; scanf("%d", &size); for(i = 0; i < size; i++){ for(j = 0; j < size; j++){ scanf("%d", &Matrix[i...
2019-01-04 11:32:41
2372
原创 13. 编写程序,使其具有以下功能: (1) 定义一个用来表示商品信息的结构体类型shangpin,该结构体包含三个成员,分别为spid、spname和spdj,其中spid表示商品号,类型为字符数
#include <stdio.h>#include <stdlib.h> typedef struct shangpin{ char spid[7]; char spname[15]; float spdj;}shangpin;int main(){ shangpin w; FILE *fp; gets(w.spid); gets(w.sp...
2019-01-04 10:40:37
3830
原创 14.编写一个名为countc函数(函数头为:int countc(char array[])),其功能是:统计array数组中所存放的字符串中大写字母的数目,并返回字符串中大写字母的数目。再编写一个
#include <stdio.h>int countc(char array[]);int main(){ #ifdef ONLINE_JUDGE #else freopen("in.txt", "r", stdin); #endif int count; char array[80]; gets(array); count = countc(arr...
2019-01-03 22:07:46
2628
原创 15. 编写一个函数mysum,其功能是计算n个整数中数值在70~80之间(含70和80)的整数的和,主函数程序的功能是从键盘输入8个整数,通过调用函数mysum计算这8个整数中数值在70~80之间的
#include <stdio.h>int mysum(int a[], int b);int main(){ #ifdef ONLINE_JUDGE #else freopen("in.txt", "r", stdin); #endif int a[8]; for(int i = 0; i < 8; i++){ scanf("%d", &am...
2019-01-03 21:54:53
3525
原创 16. 编写程序,使其具有以下功能: (1) 创建一个能够记录6个任意整数的单向链表。要求:这6个整数必须从键盘获得,并分别保存在链表的不同节点中。 (2) 使用循环语句,遍历已经创建完成的链表,求
#include <stdio.h>#include <stdlib.h>#include <bits/stdc++.h>using namespace std;typedef struct ListNode{ int data; ListNode *next;}ListNode;int main(){ #ifdef ONLINE_JU...
2019-01-03 21:45:26
1326
原创 中国大学MOOC-陈越、何钦铭-数据结构-2018秋 06-图3 六度空间 (30 分)
#include <bits/stdc++.h>using namespace std;int const MAXV = 10000;int vertex, edge;int visited[MAXV] = {0};int graph[MAXV][MAXV];int BFS(int vertex);int main(){ #ifdef ONLINE_JUDGE...
2018-12-24 23:47:55
447
原创 在Vs中调试查看队列元素
*((((*((std::_Deque_alloc&lt;std::_Deque_base_types&lt;int,std::allocator&lt;int&gt; &gt; &gt;*)(&amp;((q).c))))._Mypair)._Myval2)._Map),3
2018-12-24 22:34:10
838
原创 中国大学MOOC-陈越、何钦铭-数据结构-2018秋 Case 01-复杂度2 Maximum Subsequence Sum (25 分)
#include <iostream>#define N 10000using namespace std;int main(){ int i, n, a[N], left = 0, right = 0, maxsum = -1, currentsum = 0, temp = 0; cin >> n; for (i = 0; i <...
2018-11-24 23:09:40
584
原创 中国大学MOOC-陈越、何钦铭-数据结构-2018秋 Case1 01-复杂度2 Maximum Subsequence Sum (25 分)
#include <iostream>#define N 10000using namespace std;int main(){ int i, n, a[N], left = 0, right = 0, maxsum = -1, currentsum = 0, temp = 0, flag = 0; cin >> n; for (i =...
2018-11-24 23:07:05
520
原创 中国大学MOOC-陈越、何钦铭-数据结构-2018秋 01-复杂度2 Maximum Subsequence Sum (25 分)
https://paste.ubuntu.com/p/pVYYSy8J8d/https://paste.ubuntu.com/p/z3jChp7kZZ/
2018-11-24 21:42:55
276
原创 PTA习题8-10 输出学生成绩(20 分)
#include&lt;stdio.h&gt;#include&lt;stdlib.h&gt;int main(){ int n,i,*p; double sum=0,max,min; if((p=(int*)malloc(sizeof(int)))==NULL){ exit(1); } scanf("%d",&amp;
2018-09-04 15:55:53
9864
原创 PTA习题8-7 字符串排序(20 分)
#include<stdio.h>#include<string.h>#define M 5#define N 80int main(){ char str[M][N],tmp[N]; int i,j; for(i=0;i<M;i++){ scanf("%s",&str[i]); } for...
2018-09-03 22:24:05
12159
1
原创 习题4-6 水仙花数(20 分)
#include<stdio.h>#include<math.h>int main(){ int N,min,max,i,a,b;/*i用来遍历符合条件的整数,a作为i的副本用来处理数据 b用来存储各个位置上的数字*/ int item,sum=0; scanf("%d",&...
2018-08-30 21:08:11
2818
1
原创 习题4-5 换硬币(20 分)
#include<stdio.h>int main(){ int cnt=0,x,i,j,k; scanf("%d",&x); for(k=x/5;k>0;k--){ for(j=x/2;j>0;j--){ for(i=x;i>0;i--){ if...
2018-08-30 16:51:14
384
原创 习题4-4 特殊a串数列求和(20 分)
#include<stdio.h>#include<math.h>int main(){ int i,a,n,s1=0,s=0; scanf("%d%d",&a,&n); for(i=1;i<=n;i++){ s1+=a*pow(10,i-1); s+=s1; } ...
2018-08-30 15:05:41
1022
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人