Pat甲级解题及分析
本专栏用于个人总结思考甲级pat真题。
NightHulk
自己爬过很多坑,总结这些坑,帮助后来者
展开
-
A1046.Shortest Distance(20)
我自己写的代码#include<cstdio>#include<time.h>#define MIN(a,b) ((a)<(b)?(a):(b)) int N;//出口个数void wkk(int a,int b,int A[]) ;int main(){ int temp,temp2,j,min,max; printf("自己的代码:\n"); sc...原创 2018-06-22 09:52:06 · 228 阅读 · 0 评论 -
A1042.Shuffling Machine(20)
#include<cstdio> const int N=5;char mp[5]={'S','H','C','D','J'};//牌的编号与花色对应关系 int start[N+1],end[N+1],next[N+1];//next数组存放每个位置上的牌在操作后的位置int main(){ int K; scanf("%d",&K); for(int i =...原创 2018-06-21 10:55:30 · 195 阅读 · 0 评论 -
A1002. A+B for Polynomials(25)
自己的代码#include <cstdio>const int N=1000;int main(){ double A[N]={0}; bool B[N]={false}; int k1,temp1,max=0,count=0; double temp2; for(int i=0;i<2;i++){ scanf("%d",&k1); for(int ...原创 2018-06-26 11:38:20 · 202 阅读 · 0 评论 -
A1009.Product of Polynomials(25)
自己的代码#include<cstdio>double A[1001]={0},B[1001]={0};const int N=5;int main(){ int n1,n2,k1,k2,max=0,count=0; double temp1,temp2; scanf("%d",&n1); for(int i=0;i<n1;i++){ scanf("%d...原创 2018-06-28 14:49:28 · 184 阅读 · 0 评论 -
A1011.World Cup Bettiing(20)
自己的代码#include <cstdio>//#include <iostream> #include <cstdlib>#include <algorithm>using namespace std;struct node{ int index; double content;}B[4];int main(){ double ...原创 2018-06-28 16:29:52 · 193 阅读 · 0 评论 -
A1006.Sign In and Sign Out(25)
这里自己没有写出来,问题如下1,如何在一行输入英文id和以:分隔的时间,时间如何存储,以字符串吗,那要比较大小的时候如何转换成数字2,这里时间比较好麻烦啊,先要比较小时然后分钟然后秒,一个一个人比较吗,还是存储max和min3,感觉整体逻辑有点麻烦,看着就不想做参考代码:#include <iostream>#include <cstdio>#include <c...原创 2018-07-02 21:43:25 · 322 阅读 · 0 评论 -
A1031.Hello World for U(20)
自己的代码#include <cstdio>#include <cstring>int main(){ char str[100]; printf("请输入字符串:\n"); gets(str); int len=strlen(str); int a=(len+2)%3; int high,width;//high表示算上拐角的高度,width表示算上拐角的...原创 2018-07-08 20:23:21 · 266 阅读 · 0 评论 -
A1019.General Palindromic Number(20)
自己的代码#include <cstdio>int main(){ int n,num,i=0,temp;//定义进制数和数字 int a[20]={0};//用于存放转换为进制后的数字 scanf("%d %d",&num,&n); while(num!=0){ temp=num%n; a[++i]=temp; num=num/n; } ...原创 2018-07-10 21:06:01 · 186 阅读 · 0 评论 -
A1073.科学计数法(20)
参考代码#include <cstdio>#include <cstring> int main(){ char str[10010]; gets(str); int len=strlen(str); if(str[0]=='-') printf("-");//如果是负号,则输出负号 int pos=0;//pos存放字符串中E的位置 while(str...原创 2018-07-13 09:13:53 · 242 阅读 · 0 评论 -
A1001.A+B Format(20)
自己的代码#include <cstdio>#include <cmath>#define MaxSize 10using namespace std;typedef struct{ int data[MaxSize]; int top;}SqStack;void init2(int A[MaxSize]){ A[MaxSize]={0};}void ...原创 2018-07-14 09:51:35 · 199 阅读 · 0 评论 -
A1005.Spell It Right(20)
自己的代码#include <cstdio>#include <cstring>#define MaxSize 100int main(){ char a[10][10]={"zero","one","two","three","four","five","six","seven"原创 2018-07-16 21:04:08 · 226 阅读 · 0 评论 -
A1035.Password
自己的代码:#include <cstdio>#include <cstring>#define namesize 11#define passsize 10#define maxsize 10struct node{ char name[namesize]; char pw[passsize]; int flag=0;};void check(...原创 2018-07-17 20:00:16 · 182 阅读 · 0 评论 -
A1077.Kuchiguse(20)
参考代码//给定N个字符串,求他们的公共后缀,如果不存在公共公共后缀,则输出"nai" #include <cstdio>#include <cstring>int n,minLen=256,ans=0;char s[100][256];//至多100个字符串,每个字符串至多256个字符int main(){ scanf("%d",&n);//n...原创 2018-07-18 19:29:58 · 335 阅读 · 0 评论