自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(43)
  • 资源 (1)
  • 收藏
  • 关注

原创 NA-PTA-NA Lab2 求多项式的根

Sample program of judge:#include <stdio.h>#include <math.h>#define ZERO 1e-13 /* X is considered to be 0 if |X|<ZERO */#define MAXN 11 /* Max Polynomial Degree + 1 */double Polynomial_Root(int n, double c[], double a, double b, do.

2021-05-29 23:38:51 298 1

原创 NA-PTA-NA Lab8 Composite Simpson Itegration

Shape RoofThe kind of roof shown in Figure 1 is shaped from plain flat rectangular plastic board in Figure 2.The transection of the roof is a sine curve which fits the function y(x)=lsin(lx) in centimeters. Given the length of the roof, your task is to

2021-05-29 23:31:30 361

原创 NA-PTA-NA Lab7 正交多项式拟合的免病态方法

Orthogonal Polynomials ApproximationFormat of function:int OPA( double (*f)(double t), int m, double x[], double w[], double c[], double *eps );Sample program of judge:#include <stdio.h>#include <math.h>#define MAX_m 200#define MAX_n

2021-05-27 15:03:09 387

原创 Crypto-PTA-AES部分重要函数

AES加密算法的部分重要函数1. 加密解密函数由于AES是对称加密算法,AES加密函数与解密函数非常美观。解密是加密的完全逆序(附录有代码)2. MixColumn & MixColumnInverseMixColumn( ) 即把明文16B矩阵与标准矩阵做矩阵乘法,再转置。MixColumnInverse( ) 即把密文16B矩阵转置,再与标准矩阵做矩阵乘法。加密的标准矩阵由以3112为降幂系数的多项式转化而来。解密的标准矩阵由以DB9E为降幂系数的多项式转化而来。上面代码中ae

2021-05-14 15:42:32 361

原创 贪心算法-PTA-选择车站加油问题

To Fill or Not to FillWith highways available, driving a car from Hangzhou to any other city is easy. But since the tank capacity of a car is limited, we have to find gas stations on the way from time to time. Different gas station may give different pric

2021-05-12 21:43:23 705

原创 Crypto-DES加密核心函数-CFB模式-rc4的异或性

单次DES算法加密的流程图如下:核心函数是 f单次DES加密的核心函数是 f ,如图所示核心函数代码:static long32 f(ulong32 r, unsigned char subkey[8]) { unsigned char s[4], plaintext[8], m[4], t[4]; unsigned long int rval; //(1) 把r分成4个字节 到s (DES是大端) s[0] = (r & 0xFF000000) >> 24; //

2021-04-27 10:23:03 517

原创 动态规划-PTA-0/1背包

Programming ContestBob will participate in a programming contest. There are altogether n problems in the contest. Unlike in PAT (Programming Ability Test), in a programming contest one can not obtain partial scores. For problem i, Bob will need time[i] to

2021-04-21 22:17:03 1319

原创 NA-PTA-NA Lab5 正则化幂法求矩阵特征值

Approximating EigenvaluesApproximate an eigenvalue and an associated eigenvector of a given n×n matrix A near a given value p and a nonzero vector ​x =(x1​​ ,⋯,xn​​ )​T​​ .Format of function:int EigenV(int n, double a[][MAX_SIZE], double *lambda, double

2021-04-15 21:32:04 382

原创 NA-PTA-NA Lab6 Cubic Spline插值不要直接解方程

Format of functions:void Cubic_Spline(int n, double x[], double f[], int Type, double s0, double sn, double a[], double b[], double c[], double d[]);double S( double t, double Fmax, int n, double x[], double a[], double b[], double c[], double d[] );.

2021-04-15 16:57:10 233

原创 回溯-DFS-PTA-回溯

WerewolfWerewolf(狼人杀) is a game in which the players are partitioned into two parties: the werewolves and the human beings. Suppose that in a game,player #1 said: “Player #2 is a werewolf.”;player #2 said: “Player #3 is a human.”;player #3 said: “Playe

2021-04-09 11:58:22 271

原创 NA-PTA-NA Lab4 Jacobi迭代 与 Gauss-Seidel迭代

Compare Methods of Jacobi with Gauss-SeidelUse Jacobi and Gauss-Seidel methods to solve a given n×n linear system Ax=b​ with an initial approximation x​(0)​​ .Note: When checking each a​ii​​ , first scan downward for the entry with maximum absolute valu

2021-03-24 21:24:55 427

原创 NA-PTA-NA Lab3 线性方程组求解[严格对角占优/正定的Gauss-Seidel法]

There is No Free LunchFormat of function:void Price( int n, double p[] );where int n satisfies that 2< n ≤10000; double p[ ] is passed into the function as an array of prices p​i​​ and then will be returned storing the costs of the dishes.Sample

2021-03-18 16:42:31 320 1

原创 Crypto-PTA-Enigma破解

Advanced Engima Cracking题目要求本题目需要模拟当年破解Enigma的过程,现在我们已经知道Plugboard, RingSetting, CipherText 和 Word已知 PlainText 中一定包含单词 Word, 求破解 MessageKey, PlainText 和 RotorNum由于完全破解耗时太长,输入还会给出3个齿轮中最左侧那个齿轮的编号。提示建议你实现一个加密/解密函数 与http://10.71.45.100/bhh/MyEnigma.exe 产

2021-03-16 21:52:11 933

原创 树-PTA-B+树的插入操作 [含换行的层序遍历]

Self-printable B+ TreeIn this project, you are supposed to implement a B+ tree of order 3, with the following operations: initialize, insert (with splitting) and search. The B+ tree should be able to print out itself.Input Specification:Each input file

2021-03-14 16:23:52 1446

原创 Crypto-Enigma密码机原理

Enigma密码机是二战德军使用的密码机,是密码系统中出色的设计。构件:5个rotor(转子/齿轮):编号I、II、III、IV、V,每次选其中3个使用。每个rotor上均存在着26个字母到自身的一一映射表,且各不相同。Plugboard(接线板):内含26个接线柱,表示26个字母。将某两个字母连起即可实现这两个字母的相互转化(即按A出B,按B出A);reflector(反射板):将26字母两两配对,实现配对的两个字母的相互转化。加密过程:加密过程要经过5个元件:(以明文A为例)开始时输

2021-03-08 22:14:06 3981

原创 NA-PTA-NA Lab1 Hamming级数求和 [递推求级数和以减小误差]

Produce a table of the values of the seriesfor the 3001 values of x, x = 0.0, 0.1, 0.2, …, 300.00. All entries of the table must have an absolute error less than 10^−10. This problem is based on a problem from Hamming (1962), when mainframes were very sl

2021-03-07 21:34:11 1371

原创 树-PTA-AVL树的构建 [递归求节点高度]

Root of AVL TreeAn AVL tree is a self-balancing binary search tree. In an AVL tree, the heights of the two child subtrees of any node differ by at most one; if at any time they differ by more than one, rebalancing is done to restore this property.Now giv

2021-03-05 15:10:30 235

原创 归并排序用一个函数

归并排序再也不用两个函数了void msort(int a[], int tmp[], int start, int end) { int p; int mid = (start + end) >> 1; if (start < end) { msort(start, mid); msort(mid + 1, end); } else return; //递归出口 //两边排序完成 归并 int i = start, j = mid + 1, k =

2021-01-13 21:51:12 277

原创 图-PTA-寻找强连通分支&寻找关节点 思路的相似性

Write a program to find the strongly connected components in a digraph.Format of functions:void StronglyConnectedComponents( Graph G, void (*visit)(Vertex V) );where Graph is defined as the following:typedef struct VNode *PtrToVNode;struct VNode {

2021-01-13 17:48:33 1150

原创 图-PTA-判断给定序列是否是拓扑排序

Is Topological OrderWrite a program to test if a give sequence Seq is a topological order of a given graph Graph.Format of functions:bool IsTopSeq( LGraph Graph, Vertex Seq[] );where LGraph is defined as the following:typedef struct AdjVNode *PtrToAd

2021-01-13 16:59:19 1303

原创 输出所有组合

一种非递归的组合问题的解决方法默认是从1-n这n个数中取m个,有多少种组合其他诸如字符、字符串等的组合问题均可建立映射表解决总体思路是对所有组合进行分类,进位前后分为两类1234 1235 1236为一类1245 1246 为一类1256 为一类1345 1346为一类1356为一类……每一次大的while循环解决“一类组合的输出”和“下一类的预备”工作#include <stdio.h> #include <stdlib.h> int combine

2020-12-05 16:34:20 728

原创 不相交集-PTA-数组实现不相交集及Union, Find, Check操作

File TransferWe have a network of computers and a list of bi-directional connections. Each of these connections allows a file transfer from one computer to another. Is it possible to send a file from any computer on the network to any other?Input Specifi

2020-12-04 13:35:04 336

原创 图-有向带权图的十字邻接表的数组实现

有向图需要用十字邻接表来表示。但用链表实现十字邻接表是非常苦恼的,代码很容易便会达到数百行。事实上有一种数组实现十字邻接表,不用指针便可解决有向带权图的问题(含重边,自环)。 理论上有向图解决了,无向图也可以被解决。输入格式4 51 4 94 3 81 2 52 4 61 3 7输入时点也可以是点的名称,此时需要建立点的名称字符串与点号的映射表。方法解读i 号点的第一条边边号为 first[i];i 号边的出点的下一条边边号为 next[i];特点① 以边号为主要操作对象。

2020-12-03 19:52:11 705

原创 堆-堆的基本概念与操作

堆(heap)又名优先队列(priority queue),是一种特殊的树。1. 堆的两个性质:① structure property: 是一个完全二叉树;因此可用数组表示,BT[n+1]的形式,BT[0]为dummy.② order property: (min heap为例,大小关系变反之后则为max heap)表述一:每个子树的根的值都比子树中其他值小;表述二:每个结点的值都比左右子小;表述三:从根到任何叶的(唯一)路径上,结点的值递增;2. 堆的父子结点3. 堆的基本操作(

2020-11-18 21:40:14 753

原创 树-表达式树与prefix/infix/postfix的转换

众所周知· 前缀/中缀/后缀表达式中的任意一个,都可以唯一确定一个表达式树;· 对于表达式树进行前序/后序遍历可以得到前缀/后缀表达式,进行每次加括号的中序遍历可以得到中缀表达式。· prefix, infix, postfix, syntax tree四者两两均构成双射。我们这里来讨论如何实现由三种表达式构造表达式树。为了简便,我们只考虑中缀表达式带有全部括号的情况。(若完全不带有括号,则它根本不是中缀表达式,也不对应着唯一的表达式树。若只带有必要的括号,则可以先用其他方法将其变成带有全部括号的

2020-11-15 20:23:19 636

原创 链表-PTA-链表的游标实现

Merging Linked ListsGiven two singly linked lists L​1​​=a​1​​→a​2​​→⋯→a​n−1​​→a​n​​ and L​2​​=b​1​​→b​2​​→⋯→b​m−1​​→b​m​​. If n≥2m, you are supposed to reverse and merge the shorter one into the longer one to obtain a list like a​1​​→a​2​​→b​m​​→a​3​​→a​4

2020-11-14 15:13:24 311

原创 二叉树-PTA-递归构造完全二叉搜索树

A Binary Search Tree (BST) is recursively defined as a binary tree which has the following properties:The left subtree of a node contains only nodes with keys less than the node’s key.The right subtree of a node contains only nodes with keys greater than

2020-11-14 15:13:13 562 1

原创 树-PTA-蛇形输出树[由中序后序构造树][递归求节点层数]

Suppose that all the keys in a binary tree are distinct positive integers. A unique binary tree can be determined by a given pair of postorder and inorder traversal sequences. And it is a simple standard routine to print the numbers in level-order. However

2020-11-14 15:12:59 186

原创 双向队列-PTA-双向队列的插删

A “deque” is a data structure consisting of a list of items, on which the following operations are possible:Push(X,D): Insert item X on the front end of deque D.Pop(D): Remove the front item from deque D and return it.Inject(X,D): Insert item X on the r

2020-11-14 15:11:12 205

原创 栈-PTA-判断给定出栈结果是否可实现

Given a stack which can keep M numbers at most. Push N numbers in the order of 1, 2, 3, …, N and pop randomly. You are supposed to tell if a given sequence of numbers is a possible pop sequence of the stack. For example, if M is 5 and N is 7, we can obtain

2020-11-14 15:10:59 180

原创 数组-PTA-类似二分法解决有序数组的插入

高等教育出版社教材-浙大版《数据结构(第2版)》题目集。有序数组的插入本题要求将任一给定元素插入从大到小排好序的数组中合适的位置,以保持结果依然有序。函数接口定义:bool Insert( List L, ElementType X );其中List结构定义如下:typedef int Position;typedef struct LNode *List;struct LNode { ElementType Data[MAXSIZE]; Position Last; /*

2020-11-14 14:35:46 520

原创 二叉树-递归计算某节点的层数/深度

该函数需要传入某已知节点、该节点的depth/level和目标节点,将返回目标节点的depth/level目标节点在已知节点的子树中才可以,通常传入整个树,如下 level = Rec_GetLevel(t, 1, target);#include <stdio.h>#include <stdlib.h>#include <stdbool.h>#define NOT_FOUND -999typedef struct node{ int Element;

2020-10-14 13:38:26 3051

原创 栈-PTA-支持负数与小数的“atoi”函数

Format of functions:ElementType EvalPostfix( char *expr );where expr points to a string that stores the postfix expression. It is guaranteed that there is exactly one space between any two operators or operands. The function EvalPostfix is supposed to r

2020-09-28 19:17:45 399

原创 scanf-PAT-读入空格间隔的多个字符串

给定一句英语,要求你编写程序,将句中所有单词的顺序颠倒输出。输入格式:在一行内给出总长度不超过 80 的字符串。字符串由若干单词和若干空格组成,其中单词是由英文字母(大小写有区分)组成的字符串,单词之间用 1 个空格分开,输入保证句子末尾没有多余的空格。输出格式:输出占一行,输出倒序后的句子。输入样例:Hello World Here I Come输出样例:Come I Here World Hello我的答案#include<stdio.h>#include<s

2020-09-24 16:32:29 526

原创 链表-PAT-&&||的执行顺序避免访问NULL

设计函数求一元多项式的导数。输入格式:以指数递降方式输入多项式非零项系数和指数。输出格式:以与输入相同的格式输出导数多项式非零项的系数和指数。“零多项式”的指数和系数都是 0,但是表示为 0 0。输入样例:3 4 -5 2 6 1 -2 0输出样例:12 3 -10 1 6 0我的答案#include<stdio.h>#include<stdlib.h>typedef struct term{ int coe; int exp; struct ter

2020-09-24 16:27:24 183

原创 小内存大数据排序-[多路归并法][文件一些的操作]

总结一下几个文件操作注意点。新打开文件时注意括号注意 赋值= 的优先级低于 比较==一定要(fp = fopen("in.txt", "r")) == NULL注意一些惯用操作FILE* fp; if ((fp = fopen("in.txt", "r")) == NULL) printf("Open Fail."); else { for(i = 0; i &lt...

2020-04-28 18:17:13 909

原创 归并排序-拓展至三路归并

#include <stdio.h>#include <stdlib.h>#define MAX 999999 //一个比所传入最大值要大的数即可void Sort(int* a, int* temp, int low, int high);void GuiBing(int* a, int* temp, int low, int high);int main(vo...

2020-04-26 14:17:00 1684

原创 随机数-每次运行程序均生成不同的随机数[系统时间作为生成种子]

很多算法问题在它们的解决方案中都和排序有关。例如,可以根据随机键值“排序”,以打乱一个数组。一种方法就是使用选择排序算法,然后把找到最小值的位置改成选择一个随机位置。该结果是一个打乱算法,其中各种可能的输出是等概率的。编写一个程序,通过随机排序输出1-52之间的整数。#include<stdio.h>#include<stdlib.h>#include <ti...

2020-04-17 10:09:22 986

原创 Project-符合人类习惯的多元多项式计算器

main.h#include <stdio.h>#include <stdlib.h>#include <string.h> #define MAXASC 127#define MAXINT 32767#define min(a,b) ((a)>(b)?(b):(a))typedef struct Poly{ int coef; int ...

2020-03-30 08:51:57 714

原创 链表-PTA-奇数值结点链表[三指针法将链表分为两链]

本题对头结点的分类讨论(在读入与操作函数中)可能可以运用“空头结点”进行简化,但是主要想强调运用“三指针”可将链表分为两链。本题要求实现两个函数,分别将读入的数据存储为单链表、将链表中奇数值的结点重新组成一个新的链表。链表结点定义如下:struct ListNode { int data; ListNode *next;};函数接口定义:struct ListNode ...

2020-03-21 16:59:49 430

自然语言习惯的多元多项式计算器

程序功能介绍: 1、可进行多元多项式的加减乘运算 2、多项式的输入输出完全符合人类书写习惯(系数1、-1、0 指数1、0时) 3、输入无升降幂要求,交叉项内字母无顺序要求 4、支持区分大小写的52种字母作为变元 5、指数最大32767, 系数最大2^32 6、结果以升幂输出,交叉项内字母按ASCII表排列 7、输入两个多项式可进行多次运算 8、支持合并同类项、合并同底数幂功能

2020-04-19

空空如也

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

TA关注的人

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