自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

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

原创 PAT A1056 Mice and Rice

#include <stdio.h>#include <algorithm>#include <string.h>#include <math.h>#include <stack>#define MAXN 1010using namespace std;typedef struct{ int id; ...

2020-01-31 15:30:19 61

原创 PAT A1051 Pop Sequence

#include <stdio.h>#include <string.h>#include <stack>using namespace std;int main(){ //freopen("input.txt","r",stdin); int m,n,k; int i,j,now; stack<int&g...

2020-01-31 12:48:34 75

原创 PAT A1071 Speech Patterns

不知道错哪里了。。。#include <stdio.h>#include <iostream>#include <string>#include <string.h>#include <map>#include <ctype.h>#define MAXN 10000using namespace std;...

2020-01-30 10:59:04 78

原创 PAT A1049 Counting Ones

#include <stdio.h>#include <string.h>#include <stdlib.h>#include <math.h>#define maxn 20int Figure(int num){ if(num/10==0)return 1; else return Figure(num/10)+1...

2020-01-28 10:44:42 86

原创 PAT A1046 Shortest Distance

Description:The task is really simple: given N exits on a highway which forms a simple cycle, you are supposed to tell the shortest distance between any pair of exits.Input Specification:Each input...

2020-01-23 22:18:40 68

原创 PAT A1077 Kuchiguse

Description:The Japanese language is notorious for its sentence ending particles. Personal preference of such particles can be considered as a reflection of the speaker’s personality. Such a preferen...

2020-01-23 11:47:04 79

原创 PAT A1035 Password

Description:To prepare for PAT, the judge sometimes has to generate random passwords for the users. The problem is that there are always some confusing passwords since it is hard to distinguish 1 (on...

2020-01-23 10:39:26 74

原创 PAT A1005 Spell It Right

Description:Given a non-negative integer N, your task is to compute the sum of all the digits of N, and output every digit of the sum in English.Input Specification:Each input file contains one tes...

2020-01-23 10:07:14 57

原创 PAT A1001 A+B Format

Description:Calculate a+b and output the sum in standard format – that is, the digits must be separated into groups of three by commas (unless there are less than four digits).Input Specification:E...

2020-01-22 23:41:55 86

原创 PAT B1048数据加密

题目描述:本题要求实现一种数字加密方法。首先固定一个加密用正整数 A,对任一正整数 B,将其每 1 位数字与 A 的对应位置上的数字进行以下运算:对奇数位,对应位的数字相加后对 13 取余——这里用 J 代表 10、Q 代表 11、K 代表 12;对偶数位,用 B 的数字减去 A 的数字,若结果为负数,则再加 10。这里令个位为第 1 位。输入格式:输入在一行中依次给出 A 和 B,均为不超...

2020-01-22 22:34:46 148

原创 PAT B1024/A1073科学计数法

问题描述:科学计数法是科学家用来表示很大或很小的数字的一种方便的方法,其满足正则表达式 [±][1-9].[0-9]+E[±][0-9]+,即数字的整数部分只有 1 位,小数部分至少有 1 位,该数字及其指数部分的正负号即使对正数也必定明确给出。现以科学计数法的格式给出实数 A,请编写程序按普通数字表示法输出 A,并保证所有有效位都被保留。输入格式:每个输入包含 1 个测试用例,即一个以科...

2020-01-22 20:24:38 228

原创 PAT A1061/B1014字符串处理

题目描述:大侦探福尔摩斯接到一张奇怪的字条:我们约会吧! 3485djDkxh4hhGE 2984akDfkkkkggEdsb s&hgsfdk d&Hyscvnm。大侦探很快就明白了,字条上奇怪的乱码实际上就是约会的时间星期四 14:04,因为前面两字符串中第 1 对相同的大写英文字母(大小写有区分)是第 4 个字母 D,代表星期四;第 2 对相同的字符是 E ,那是第 5 个...

2020-01-22 16:35:03 113

原创 13_6查找字符串

题目描述:输出第二个字符串在第一个字符串中的起始和终止位置,如果没有则输出0。AC代码#include <stdio.h>#include <stdlib.h>#include <string.h>int main(){ char s1[]="abcdefgh"; char s2[]="cdef"; char *p=st...

2020-01-20 19:06:57 153

原创 13_5N皇后问题

问题描述:N皇后问题,在"5.in"中给定棋盘的大小n,在"5.out"中输出放置方法的个数。相关:codeup八皇后问题D递归解决全排序(字典序)测试:n=4 num=2n=8 num=92AC代码#include <stdio.h>#include <stdlib.h>#include <math.h>#define maxn 10...

2020-01-20 18:21:22 208

原创 输入测试

Note:输入带有数字和其他字符的字符串,x会接受到第一个数字,ch不会接收第一个数字之后的字符,而接手第一个字符

2020-01-20 17:00:57 278

原创 13_1234

问题描述:在"1.in"中有几个正整数,把这几个正整数中的最大值输出到"1.out"AC代码#include <stdio.h>#include <vector>#include <algorithm>using namespace std;int main(){ vector<int>a; int x; ...

2020-01-20 16:21:23 132

原创 14_4拓扑排序

题目描述:要求用文件进行输入,判断有无拓扑排序,有则输出,无则说明sample input:3 20 1 21 2sample output:有拓扑排序:0 1 2sample input:3 30 1 21 22 0sample output:无拓扑排序AC代码#include <stdio.h>#include <vector&gt...

2020-01-20 15:46:46 85

原创 14_3幂集合运算

题目描述:用屏幕输入一行单词,然后对这些单词进行幂集合运算,并输出之Note:幂集合运算是什么??

2020-01-20 15:09:59 828 1

原创 14_2求解方程组

题目描述:求多项式ax^11 - 3x^8 - 5x^3 - 1 = 0,的根要求a用屏幕进行输入,根的精度为0.0000001,并且说可能无解AC代码不会

2020-01-20 14:59:02 104

原创 14_1随机数问题

题目描述:写一个函数,输出100个1和10000之间的随机数,并统计1-1000,1001-2000.。。。9001-10000之间各有多少个数。AC代码#include <stdio.h>#include <time.h>#include <stdlib.h>int myrand(){ srand((unsigned)time(NULL)...

2020-01-20 14:26:48 285

原创 12_3拓扑排序

任务调度:从task.in 文件中读入任务调度序列,输出n个任务适合的一种调度方式到task.out中。每行第一个表示前序任务,括号中的任务为若干个后序任务,表示只有在前序任务完成的情况下,后序任务才能开始。若后序为NULL则表示无后继任务。知识点:从字符串中解决#include <stdio.h>#include <cstring>#include <a...

2020-01-20 13:52:55 106

原创 12_5求解字典序最小的最短路径

#include <stdio.h>#include <cstring>#include <algorithm>#include <vector>#define maxn 510#define INF 1e8using namespace std;vector<int>temp,ans;vector<int&gt...

2020-01-19 21:22:59 1764

原创 15_3树(普通)的层序遍历

题目描述:从文件input_3.txt输入一个树,建树并输出层数为奇数的节点到output_3.txt中。sample input:A B CB DC E F HD Gsample output:第一层:A第三层:D,E,F,HAC代码#include <stdio.h>#include <string.h>#include <vecto...

2020-01-19 18:54:42 162

原创 12_4火车票问题

题目描述:火车票订购:火车经过X站,火车最大载客人数为m,有n个订票请求,请求订购从a站到b站的k张票,若能满足订购要求则输出1,否则输出0。数据从ticket.in中输入,第一行有四个数,分别为n,m。接下来有n行,每行三个数分别为a,b,k。结果输出到文件ticket.out中。Sample Input:5 10 ...

2020-01-19 10:19:42 426

原创 12_2最大公约数问题

题目描述:从number.in 文件中读入n个数,求出这n个数的最小值、最大值以及它们两的最大公约数,输出到文件number.out中。number.in中第一行为n,接下来为n个大于零的整数。sample Input:34 8 6sample output:4 8 4知识点:最大公约数和最小公倍数AC代码#include <stdio.h>int gcd(...

2020-01-18 23:12:28 354

原创 12_1字符串问题

问题描述:字符串处理:从string.in文件里读入两个字符串,字符串除了数字还可能包括 ‘—’、‘E’、‘e’、’.’,相加之后输出到文件string.out中,如果是浮点型,要求用科学计数法表示(最多包含10个有效数字)。Sample Input:34.56 2.45e2Sample Output: 2.795...

2020-01-18 22:44:51 833 1

原创 15_4最短路径

题目描述:从文件input.txt中输入一个图,要求输出从1经过k到n的最短路径,可以有环,输出到output.txt中。sample input:5 3//n,k1 2 10 5 302 3 203 4 60 5 104 5 205sample output:1 2 3 5Note:文件的输入输出和Dijkstra算法;先求出1到k的最短路径,再求出k到n的最短路径...

2020-01-18 20:42:56 161

原创 PAT A1030 Travel Plan

Note:复试真题回忆版描述不清,改为在PAT上练习

2020-01-17 21:14:15 122

原创 15_3 静态二叉树的层序遍历

题目描述:输出树的层次遍历的奇数层的所有结点。从input_3.txt 输入输入格式:A B C//非叶子结点与其孩子B EC F G输出道output_3.txt:输出格式:第1 层结点:A第3 层结点:E,F,GAC代码#include <stdio.h>#include <stdlib.h>#include <string.h&g...

2020-01-17 21:04:26 246 1

原创 12_4 静态二叉树的建立和遍历

sample1 input: 4//结点个数1 2 4//分别为编号和左右子树2 0 33 0 04 0 0sample1 output:sample2 input:75 4 34 2 13 7 92 0 0 1 0 07 0 09 0 0sample2 output:AC代码#include <stdio.h>#define maxn 1...

2020-01-17 18:15:55 133

原创 15_1字符串问题

题目描述:输出abcdefghij 任取5 个字符所有组合,不能有重复,输出到控制台格式:第1 种组合:a,b,c,d,e第种组合:…测试结果:AC代码1#include <stdio.h>#include <stdlib.h>#include <string.h>#define tot 5char ans[50];int len=0...

2020-01-17 14:09:01 268

原创 17B_4二叉树的遍历

题目描述:给定一棵二叉树的前序遍历和后序遍历,给出一种可能的中序遍历结果。从文件input.txt中读入序列,结果输出到output.txt;第一行是前序序列,第二行是后序序列,结点名称用大写字母表示,最多26个结点。sample input:A B D C ED B E C Asample output:D B A E CAC代码待解决...

2020-01-17 00:06:31 108

原创 17B_3程序改错

纠正程序错误,要求:(1)不能在func1函数中建立新的变量(2)不能把func1函数中的计算功能放到main函数中(3)不能把main函数的结果输出功能放到func1函数中,就是不能将printf语句移动到func1中原程序:#include <stdio.h>#include <stdlib.h>#include <time.h>void ...

2020-01-16 23:22:44 73

原创 17B_2微信红包分配

问题描述:编程实现一个简单的微信红包分配算法,满足要求即可:(1)键盘输入红包的总金额X元,以及红包个数N,例如10.88,表示10.88元。N是正整数。(2)每个红包的金额至少为1分钱,如果总金额无法满足这一条件,则提示重新输入。(3)在红包金额固定的条件下,单个红包的金额随机生成,且最小金额可以是1分钱。(4)屏幕上输出红包分配结果。sample input:100 5//红包金额100...

2020-01-16 22:09:57 239

原创 17B_1进制转换

问题描述:设计程序,将用户输入的十进制正整数转化成十六进制数,并在屏幕上显示AC代码#include <stdio.h>#define maxn 1000int a[maxn];int n=0;void transform(int num){ while(num!=0) { a[n++]=num%16; num/=16...

2020-01-16 19:57:47 222

原创 17A_3等差数列问题

scanf函数返回成功读入的数据项数,读入数据时遇到了“文件结束”则返回EOF。如:scanf("%d %d",&a,&b);函数返回值为int型。如果a和b都被成功读入,那么scanf的返回值就是2;如果只有a被成功读入,返回值为1;如果a和b都未被成功读入,返回值为0;如果遇到错误或遇到end of file,返回值为EOF。end of file为Ctrl+z ...

2020-01-16 18:20:29 189

原创 不指定数列长度,从文件中读入数列和从键盘输入数列

从文件中读入数列:#include <stdio.h>#define maxn 100;//开一个大数组int main(){ int test[maxn]; int n=0;//n为数组长度 freopen("input.txt","r",stdin); while(scanf("%d",test+n)!=EOF) n++;}从键...

2020-01-16 18:15:23 267

原创 17A_4图的遍历

题目描述:AC代码:#include <stdio.h>#define maxn 22int ansG[maxn][maxn]={0};int tempG[maxn][maxn]={0};int visited[maxn];int n;int i,j;void copy(){ for(int i=1;i<=n;i++) { ...

2020-01-16 15:48:46 171

原创 PAT A1068 Find More Coins

#include <stdio.h>#include <stdlib.h>#define maxn 10010#define maxv 110/* 当i=n,j=m时,最开始选是从第n个开始选,所以排序的时候要从大到小排序,先选小的 如果要求序列最大,那么排序从小到大排序*/int compare(const void*a,const void*b)...

2020-01-16 14:28:02 66

原创 17A_2完数和盈数

题目描述:输出2到1000的完数和盈数,完数(盈数)为其因子之和等于(大于)该数,测试结果:AC代码:#include <stdio.h>int a[1001]={0};int isComplete(int num){ int sum=0; for(int i=1;i<num;i++) { if(num%i==0){...

2020-01-15 21:58:19 832

空空如也

空空如也

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

TA关注的人

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