C++
KrisFeng00
这个作者很懒,什么都没留下…
展开
-
快速排序记录
快速排序记录 解释说明 传入一个数组以及low 和high,将数组下标为low的值作为枢轴,分别从数组两边往中间走,比枢轴小的放左边,大的放右边,递归调用实现排序 // 用第一个元素将等待排序的数组划分成左右两个部分 int Partition(int A[], int low, int high){ int pivot = A[low]; while (low < high) { while (low < high && A[high] >原创 2021-09-23 20:56:09 · 57 阅读 · 0 评论 -
1049 数列的片段和 (20 分)
1049 数列的片段和 (20 分) 给定一个正数数列,我们可以从中截取任意的连续的几个数,称为片段。例如,给定数列 { 0.1, 0.2, 0.3, 0.4 },我们有 (0.1) (0.1, 0.2) (0.1, 0.2, 0.3) (0.1, 0.2, 0.3, 0.4) (0.2) (0.2, 0.3) (0.2, 0.3, 0.4) (0.3) (0.3, 0.4) (0.4) 这 10 个片段。 给定正整数数列,求出全部片段包含的所有的数之和。如本例中 10 个片段总和是 0.1 + 0.3 +原创 2021-09-09 16:22:51 · 71 阅读 · 0 评论 -
1024 科学计数法 (20 分)
1024 科学计数法 (20 分) 科学计数法是科学家用来表示很大或很小的数字的一种方便的方法,其满足正则表达式 [±][1-9].[0-9]+E[±][0-9]+,即数字的整数部分只有 1 位,小数部分至少有 1 位,该数字及其指数部分的正负号即使对正数也必定明确给出。 现以科学计数法的格式给出实数 A,请编写程序按普通数字表示法输出 A,并保证所有有效位都被保留。 输入格式: 每个输入包含 1 个测试用例,即一个以科学计数法表示的实数 A。该数字的存储长度不超过 9999 字节,且其指数的绝对值不超过原创 2021-09-06 17:11:46 · 58 阅读 · 0 评论 -
1093 字符串A+B (20 分)
1093 字符串A+B (20 分) 给定两个字符串 A 和 B,本题要求你输出 A+B,即两个字符串的并集。要求先输出 A,再输出 B,但重复的字符必须被剔除。 输入格式: 输入在两行中分别给出 A 和 B,均为长度不超过 10 6 的、由可见 ASCII 字符 (即码值为32~126)和空格组成的、由回车标识结束的非空字符串。 输出格式: 在一行中输出题面要求的 A 和 B 的和。 输入样例: This is a sample test to show you_How it works 输出样例 Th原创 2021-08-19 11:09:41 · 45 阅读 · 0 评论 -
1009 Product of Polynomials (25 分)
1009 Product of Polynomials (25 分) This time, you are supposed to find A×B where A and B are two polynomials. Input Specification: Each input file contains one test case. Each case occupies 2 lines, and each line contains the information of a polynomial:K原创 2021-04-07 13:20:39 · 48 阅读 · 0 评论 -
1008 Elevator (20 分)
1008 Elevator (20 分) The highest building in our city has only one elevator. A request list is made up with N positive numbers. The numbers denote at which floors the elevator will stop, in specified order. It costs 6 seconds to move the elevator up one fl原创 2021-04-07 09:10:47 · 44 阅读 · 0 评论 -
1007 Maximum Subsequence Sum (25 分)
1007 Maximum Subsequence Sum (25 分)原创 2021-04-06 20:25:41 · 54 阅读 · 0 评论 -
最大字段和
最大字段和方法总结 一、暴力解法 找出所有的子序列,分别比较,这个方法可以说简单易懂,但是效率不高。(不推荐) #include <iostream> #include <cstring> #include <string> using namespace std; int MaxSum(int array[]){ int maxSum = 0, tempSum; int count = sizeof(array); for(int i = 0;原创 2021-04-06 19:21:40 · 135 阅读 · 0 评论 -
PTA1002A+B for Polynomials
PTA 1002A+B for Polynomials1002 A+B for Polynomials (25分) 1002 A+B for Polynomials (25分) This time, you are supposed to find A+B where A and B are two polynomials. Input Specification: Each input file contains one test case. Each case occupies 2 lines, and原创 2021-03-29 10:08:21 · 77 阅读 · 0 评论