- 博客(36)
- 资源 (6)
- 收藏
- 关注
翻译 PAT乙级——我要通过
“答案正确”是自动判题系统给出的最令人欢喜的回复。本题属于 PAT 的“答案正确”大派送 —— 只要读入的字符串满足下列条件,系统就输出“答案正确”,否则输出“答案错误”。得到“答案正确”的条件是:字符串中必须仅有P、A、T这三种字符,不可以包含其它字符; 任意形如xPATx的字符串都可以获得“答案正确”,其中x或者是空字符串,或者是仅由字母A组成的字符串; 如果a...
2019-07-25 11:59:48 220
原创 scanf和gets读取字符串时的区别
使用scanf("%s",str)读取字符串时,会以空白符(空格、Tab等)和换行符为截至标志,如果一行中有空格,那么scanf只能读取第一个空格前的字符串。 使用gets(str)读取字符串时,会以换行符为截至标志。也就是说,gets可以读取包括空格在内的一整行字符串。可以推出,如果一行只有一个换行符(即该行直接“回车”了),那么将得到空字符串(NULL)。例如,如果要在scanf读取...
2019-07-25 11:30:47 918
翻译 PAT甲级——Quick Sort
There is a classical process namedpartitionin the famous quick sort algorithm. In this process we typically choose one element as the pivot. Then the elements less than the pivot are moved to its le...
2019-07-25 10:45:35 123
翻译 快速排序的C++实现
#include "pch.h"#include <iostream>using namespace std;int Partition(int A[], int left, int right){ int temp = A[left]; //将A[left]存放至临时变量temp while (left<right)//只要left和right不相遇 { ...
2019-07-24 11:37:59 78
翻译 归并排序的C++实现
#include "pch.h"#include <iostream>#include<algorithm>using namespace std;const int maxn = 100;//将数组A的[L1,R1]和[L2,R2]区间合并为有序区间(此处的L2即为R1+1)void merge(int A[], int L1, int R1, int ...
2019-07-24 11:06:40 106
原创 PAT甲级——Median
题目描述Given an increasing sequence S of N integers, the median is the number at the middle position. For example, the median of S1={11, 12, 13, 14} is 12, and the median of S2={9, 10, 15, 16, 17} is...
2019-07-24 09:46:25 157
翻译 PAT甲级——完美数列
According to Wikipedia:Insertion sortiterates, consuming one input element each repetition, and growing a sorted output list. Each iteration, insertion sort removes one element from the input data,...
2019-07-23 10:32:13 127
翻译 PAT甲级——Shopping in Mars
题目描述Shopping in Mars is quite a different experience. The Mars people pay by chained diamonds. Each diamond has a value (in Mars dollars M$). When making the payment, the chain can be cut at any...
2019-07-22 10:08:13 97
原创 PAT甲级——Radix*
Given a pair of positive integers, for example, 6 and 110, can this equation 6 = 110 be true? The answer isyes, if 6 is a decimal number and 110 is a binary number.Now for any pair of positive inte...
2019-07-19 10:41:29 163
转载 C++中的upper_bound和lower_bound函数
部分内容转载自https://blog.csdn.net/jsjwangxinleijsj/article/details/82020825upper_bound():返回的是被查序列中第一个大于查找值得指针;lower_bound():返回的是被查序列中第一个大于等于查找值的指针;如下图所示:一、lower_bound;用法:int t=lower_b...
2019-07-18 14:50:15 1632 1
翻译 PAT甲级——完美数列
Given a sequence of positive integers and another positive integerp. The sequence is said to be aperfect sequenceifM≤m×pwhereMandmare the maximum and minimum numbers in the sequence, respecti...
2019-07-18 14:41:00 178
翻译 PAT甲级——Recover the Smallest Number
Given a collection of number segments, you are supposed to recover the smallest number from them. For example, given { 32, 321, 3214, 0229, 87 }, we can recover many numbers such like 32-321-3214-0229...
2019-07-18 09:58:41 126
翻译 4.Matlab——数组索引
4.1 双下标索引:魔方数组:行列以及对角线的元素加起来和为一个定值4.2 单下标索引:从第一列往下数,直到满足个数4.3 双下标索引转换为单下标索引:4.4 单下标转化为双下标索引:...
2019-07-16 16:45:46 1309
翻译 3.Matlab——数组大小
3.1 size函数:3.2 length函数:返回数组中尺寸较大维度的长度3.3 numel:返回元素总个数,m行n列,则总个数=m*n
2019-07-16 16:04:12 5084
翻译 2.Matlab——数组的创建
2.1向量clc:清空命令行向量生成:列向量生成 :转置:向量的步长生成方式:步长省略后默认值为1个数n省略后,默认值为1002.2二维数组:直接创建:通过函数创建:ones(n):zeros(m,n):eye(n):rand(n):randn(n) :ra...
2019-07-16 15:32:18 1927
翻译 PAT甲级——Sort With Swap(0,*)
题目描述Given any permutation of the numbers {0, 1, 2,..., N-1}, it is easy to sort them in increasing order. But what if Swap(0, *) is the ONLY operation that is allowed to use? For example, to sort...
2019-07-16 11:37:37 118
原创 PAT甲级—— Magic Coupon
题目描述The magic shop in Mars is offering some magic coupons. Each coupon has an integer N printed on it, meaning that when you use this coupon with a product, you may get N times the value of that p...
2019-07-16 09:54:33 116
原创 PAT甲级——To Fill or Not to Fill
题目描述With 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. Dif...
2019-07-15 11:32:06 91
原创 PAT乙级——组个最小数
题目描述给定数字0-9各若干个。你可以以任意顺序排列这些数字,但必须全部使用。目标是使得最后得到的数尽可能小(注意0不能做首位)。例如:给定两个0,两个1,三个5,一个8,我们得到的最小的数就是10015558。现给定数字,请编写程序输出能够组成的最小的数。输入描述:每个输入包含1个测试用例。每个测试用例在一行中给出10个非负整数,顺序表示我们拥有数字0、数字1、……数...
2019-07-15 09:20:41 86
原创 PAT甲级——Find Coins
题目描述Eva loves to collect coins from all over the universe, including some other planets like Mars. One day she visited a universal shopping mall which could accept all kinds of coins as payments. ...
2019-07-12 10:38:22 91
翻译 PAT乙级——继续(3n+1)猜想
题目描述卡拉兹(Callatz)猜想已经在1001中给出了描述。在这个题目里,情况稍微有些复杂。 当我们验证卡拉兹猜想的时候,为了避免重复计算,可以记录下递推过程中遇到的每一个数。例如对n=3进行验证的时候,我们需要计算3、 5、8、4、2、1,则当我们对n=5、8、4、2进行验证的时候,就可以直接判定卡拉兹猜想的真伪,而不需要重复计算,因为这4个数已经在 验证3的时候遇到过了,我...
2019-07-12 09:27:50 163
翻译 PAT甲级—— String Subtraction
题目描述Given two strings S1 and S2, S = S1 - S2 is defined to be the remaining string after taking all the characters in S2 from S1. Your task is simply to calculate S1 - S2 for any given strings. H...
2019-07-11 11:17:02 89
原创 PAT甲级——Be Unique
题目描述Being unique is so important to people on Mars that even their lottery is designed in a unique way. The rule of winning is simple: one bets on a number chosen from [1, 104]. The first one who...
2019-07-11 10:22:40 101
原创 PAT乙级——输出PATest
给定一个长度不超过104的、仅由英文字母构成的字符串。请将字符重新调整顺序,按PATestPATest....这样的顺序输出,并忽略其它字符。当然,六种字符的个数不一定是一样多的,若某种字符已经输出完,则余下的字符仍按 PATest 的顺序打印,直到所有字符都被输出。输入格式:输入在一行中给出一个长度不超过104的、仅由英文字母构成的非空字符串。输出格式:在...
2019-07-11 09:19:32 93
原创 PAT乙级——字符统计
请编写程序,找出一段给定文字中出现最频繁的那个英文字母。输入格式:输入在一行中给出一个长度不超过 1000 的字符串。字符串由 ASCII 码表中任意可见字符及空格组成,至少包含 1 个英文字母,以回车结束(回车不算在内)。输出格式:在一行中输出出现频率最高的那个英文字母及其出现次数,其间以空格分隔。如果有并列,则输出按字母序最小的那个字母。统计时不区分大小写,输出小写字母。输...
2019-07-09 11:22:49 252
翻译 PAT乙级——到底买不买
题目描述小红想买些珠子做一串自己喜欢的珠串。卖珠子的摊主有很多串五颜六色的珠串,但是不肯把任何一串拆散了卖。于是小红要你帮忙判断一下,某串珠子里是否包含了全部自己想要的珠子?如果是,那么告诉她有多少多余的珠子;如果不是,那么告诉她缺了多少珠子。为方便起见,我们用[0-9]、[a-z]、[A-Z]范围内的字符来表示颜色。例如,YrR8RrY是小红想做的珠串;那么ppRYYGrrYBR22...
2019-07-09 10:41:02 212
原创 PAT乙级——统计同成绩学生
题目描述本题要求读入N名学生的成绩,将获得某一给定分数的学生人数输出。输入描述:输入在第1行给出不超过105的正整数N,即学生总人数。随后1行给出N名学生的百分制整数成绩,中间以空格分隔。最后1行给出要查询的分数个数K(不超过N的正整数),随后是K个分数,中间以空格分隔。输出描述:在一行中按查询顺序给出得分等于指定分数的学生人数,中间以空格分隔,但行末不得...
2019-07-09 09:29:46 78
原创 PAT乙级——旧键盘打字
题目描述旧键盘上坏了几个键,于是在敲一段文字的时候,对应的字符就不会出现。现在给出应该输入的一段文字、以及坏掉的那些键,打出的结果文字会是怎样?输入描述:输入在2行中分别给出坏掉的那些键、以及应该输入的文字。其中对应英文字母的坏键以大写给出;每段文字是不超过10^5个字符的串。可用的字符包括字母[a-z, A-Z]、数字0-9、以及下划线“_”(代表空格)、“,”、“.”、“...
2019-07-08 15:00:11 134
翻译 PAT甲级——Cars on Campus
题目描述Zhejiang University has 6 campuses and a lot of gates. From each gate we can collect the in/out times and the plate numbers of the cars crossing the gate. Now with all the information availab...
2019-07-04 14:40:07 183
原创 PAT甲级——Graduate Admission
题目描述It is said that in 2013, there were about 100 graduate schools ready to proceed over 40,000 applications in Zhejiang Province. It would help a lot if you could write a program to automate the ...
2019-07-02 13:07:25 103
原创 PAT甲级——List Grades
题目描述Given a list of N student records with name, ID and grade. You are supposed to sort the records with respect to the grade in non-increasing order, and output those student records of which the...
2019-07-02 09:27:53 91
翻译 PAT甲级——PAT Judge
题目描述The ranklist of PAT is generated from the status list, which shows the scores of the submittions. This time you are supposed to generate the ranklist for PAT.输入描述:Each input file conta...
2019-07-01 14:43:53 202
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人