PAT练习题
leizh007
这个作者很懒,什么都没留下…
展开
-
PAT-1001
题目地址:http://pat.zju.edu.cn/contests/pat-a-practise/1001C语言源码:#includeint main(){ int a,b,top,i,s[10],flag; scanf("%d %d",&a,&b); a=a+b; top=0; flag=0; if(a<0) { a=-a; flag=1; } whil原创 2013-02-22 12:11:35 · 180 阅读 · 0 评论 -
PAT1041-Be Unique
题目地址:http://pat.zju.edu.cn/contests/pat-a-practise/1041C语言源码:#include#define maxsize 10000int T[maxsize];int S[maxsize*10];int main(){ int n,i,x; for(i=0;i<maxsize;i++) T[i]=0; scanf("%d原创 2013-03-11 19:02:12 · 167 阅读 · 0 评论 -
PAT1044-Shopping in Mars
题目地址:http://pat.zju.edu.cn/contests/pat-a-practise/1044C语言源码:#include#define maxsize 100010int a[maxsize];int main(){ int sum,min,n,i,m,j; scanf("%d %d",&n,&m); min=-1; sum=0; for(i=1;i<=原创 2013-03-12 12:25:37 · 407 阅读 · 0 评论 -
PAT1045-Favorite Color Stripe
题目地址:http://pat.zju.edu.cn/contests/pat-a-practise/1045经典的DP题:最长递增子序列C语言源码:#includeint max(int a,int b){ return a>b?a:b;}int main(){ int N,M,L,i,j,Col[220],Str[10010],dp[10010],x,ma; sca原创 2013-03-12 13:52:22 · 602 阅读 · 0 评论 -
PAT1046-Shortest Distance
题目地址:http://pat.zju.edu.cn/contests/pat-a-practise/1046C语言源码:#include#define maxsize 100010int T[maxsize];int main(){ int n,i,m,sum,j,min,temp; scanf("%d",&n); sum=0; for(i=1;i<=n;i++) {原创 2013-03-12 16:11:48 · 363 阅读 · 0 评论 -
PAT1047-Student List for Course
题目地址:http://pat.zju.edu.cn/contests/pat-a-practise/1047C语言源码:#include#include#includeint cmp(const void *a,const void *b){ return *(int *)a-*(int *)b;}int S[2501][400];//这个太坑爹了,我一开始开到40000.原创 2013-03-12 17:28:43 · 389 阅读 · 0 评论 -
PAT1048-Find Coins
题目地址:http://pat.zju.edu.cn/contests/pat-a-practise/1048C语言源码:#include#include#define maxsize 100000int T[maxsize];int cmp(const void *a,const void *b){ return *(int *)a-*(int *)b;}int main原创 2013-03-12 18:50:46 · 317 阅读 · 0 评论 -
PAT1049-Counting Ones
题目地址:http://pat.zju.edu.cn/contests/pat-a-practise/1049思路如下:从高位到低位遍历给定数字:若当前数字大于1,则该位出现1的次数为,(比其更高位数字组成的数字+1)*(10^比其低位的数字个数);如32(3)23,若当前数字为加括号的3,则当前位出现1的个数为,(32+1)*(100)若当前数字等于1,则该位出现1的次数为,原创 2013-03-12 19:59:48 · 335 阅读 · 0 评论 -
PAT1050-String Subtraction
题目地址:http://pat.zju.edu.cn/contests/pat-a-practise/1050C语言源码:#include#include#define maxsize 10000char s1[maxsize],s2[maxsize];int T[maxsize];int main(){ int i,len; gets(s1); gets(s2); f原创 2013-03-13 09:10:47 · 272 阅读 · 0 评论 -
PAT1051-Pop Sequence
题目地址:http://pat.zju.edu.cn/contests/pat-a-practise/1051思路:POP序列中某个值后面比它小的元素个数小于m,且必须是降序排列。C语言源码:#includeint main(){ int a[1010]; int n,m,k,i,min,j,num; scanf("%d %d %d",&m,&n,&k); while(原创 2013-03-13 15:24:51 · 313 阅读 · 0 评论 -
PAT1052-Linked List Sorting
题目地址:http://pat.zju.edu.cn/contests/pat-a-practise/1052PAT的数据卡的太蛋疼了:(1)并不是所有输入的节点都是链表上的节点;(2)若链表为空,输出0 -1.C语言源码:#include#include#define maxsize 100010typedef struct node{ int num,key,ne原创 2013-03-13 16:23:47 · 846 阅读 · 2 评论 -
PAT1053-Path of Equal Weight
题目地址:http://pat.zju.edu.cn/contests/pat-a-practise/1053读题不认真,纠结了半天:Each path occupies a line with printed weights from the rootto the leaf in order其实针对最后输出排序:将路径(int)Stack[n]保存到(char)S[i]中,按字符原创 2013-03-14 08:19:20 · 567 阅读 · 0 评论 -
PAT1029-Median
题目地址:http://pat.zju.edu.cn/contests/pat-a-practise/1029C语言源码:#include#define maxsize 1000010long long s1[maxsize],s2[maxsize];int main(){ long long n1,n2,mid,i,j,k,x; scanf("%lld",&n1); fo原创 2013-03-23 12:58:06 · 239 阅读 · 0 评论 -
PAT1028-List Sorting
题目地址:http://pat.zju.edu.cn/contests/pat-a-practise/1028C语言源码:#include#include#includetypedef struct student{ char ID[10]; char name[10]; int grade;}student;student stu[100010];int C;int原创 2013-03-23 13:28:15 · 276 阅读 · 0 评论 -
PAT1030-Travel Plan
题目地址:http://pat.zju.edu.cn/contests/pat-a-practise/1030C语言源码:#include#includetypedef struct node{ int length,cost;}node;node A[600][600];int visited[600];node T[600];int Stack[600][600];原创 2013-03-23 12:16:45 · 438 阅读 · 0 评论 -
PAT1040-Longest Symmetric String
题目地址:http://pat.zju.edu.cn/contests/pat-a-practise/1040C语言源码:#include#includechar s[1010];int maxlen(int m,int n){ int i,j; i=m; j=n; while(i<j) { if(s[i]!=s[j]) return 0;原创 2013-03-11 18:37:22 · 221 阅读 · 0 评论 -
PAT1043-Is It a Binary Search Tree
题目地址:http://pat.zju.edu.cn/contests/pat-a-practise/1043想法是根据给的数列建二叉树根左子树右子树遍历根右子树左子树遍历若给的数列跟上述两个遍历得到的数列某个相等则YES,否则NOC语言源码:#include#includetypedef struct Bitree{ int data; struct B原创 2013-03-12 11:07:41 · 575 阅读 · 0 评论 -
PAT1042-Shuffling Machine
题目地址:http://pat.zju.edu.cn/contests/pat-a-practise/1042C语言源码:#include#includeint main(){ char s[55][10]={"O","S1","S2","S3","S4","S5","S6","S7","S8","S9","S10","S11","S12","S13", "H1","H2","原创 2013-03-12 10:07:50 · 283 阅读 · 0 评论 -
PAT-1008
题目地址:http://pat.zju.edu.cn/contests/pat-a-practise/1008C语言源码:#includeint main(){ int n,sum,a[110],i; scanf("%d",&n); for(i=1;i<=n;i++) scanf("%d",&a[i]); a[0]=0; sum=0; for(i=1;i<=n;i++)原创 2013-02-22 19:28:23 · 162 阅读 · 0 评论 -
PAT-1002
题目地址:http://pat.zju.edu.cn/contests/pat-a-practise/1002C语言源码:#includetypedef struct poly{ int exp; double coef;}poly;int main(){ poly x[30],y[30],z[30]; int k1,k2,i,j,k; scanf("%d",&k1);原创 2013-02-22 13:08:15 · 220 阅读 · 0 评论 -
PAT-1006
题目地址:http://pat.zju.edu.cn/contests/pat-a-practise/1006C语言源码:#include#include#define maxsize 1000typedef struct people{ char name[20]; int signin; int signout;}people;people p[maxsize];i原创 2013-02-22 18:41:51 · 197 阅读 · 0 评论 -
PAT-1009
题目地址:http://pat.zju.edu.cn/contests/pat-a-practise/1009C语言源码:#include#define maxsize 3000typedef struct poly{ int exp; double coef;}poly;poly a[maxsize],b[maxsize],c[maxsize],ans[maxsize],d原创 2013-02-22 23:06:03 · 283 阅读 · 0 评论 -
PAT-1004
题目地址:http://pat.zju.edu.cn/contests/pat-a-practise/1004C语言源码:#include#define maxsize 1000int T[maxsize];typedef struct family{ int top; int child[maxsize];}family;family f[maxsize];int原创 2013-02-22 17:58:50 · 472 阅读 · 1 评论 -
PAT-1007
题目地址:http://pat.zju.edu.cn/contests/pat-a-practise/1007C语言源码:#include#include#define maxsize 10010int main(){ int max,frontmax,rearmax,front,rear,sum; int n,i,a[maxsize]; scanf("%d",&n); f原创 2013-02-22 19:14:46 · 158 阅读 · 0 评论 -
PAT-1010
题目地址:http://pat.zju.edu.cn/contests/pat-a-practise/1010老是部分正确,先留着,以后再改C语言源码:#include#include#includeint main(){ long long a,b,radix; char s1[20],s2[20],s3[20]; int i,tag; scanf("%s %原创 2013-02-24 10:04:52 · 87 阅读 · 0 评论 -
PAT-1011
题目地址:http://pat.zju.edu.cn/contests/pat-a-practise/1011C语言源码:#include#includetypedef struct odd{ char s; double data;}odd;int cmp(const void *a,const void *b){ odd *aa=(odd *)a; odd *bb=原创 2013-02-24 17:48:11 · 225 阅读 · 0 评论 -
PAT-1003
题目地址:http://pat.zju.edu.cn/contests/pat-a-practise/1003有个测试点过不去,蛋疼。。。先放着,以后再改吧C语言源码:#include#include#define maxsize 600int E[maxsize][maxsize];int visited[maxsize];int shortest[maxsize]原创 2013-02-22 17:20:09 · 95 阅读 · 0 评论 -
PAT-1005
题目地址:http://pat.zju.edu.cn/contests/pat-a-practise/1005C语言源码:#include#include#define maxsize 110int main(){ char s[maxsize]; int stack[maxsize],top,i,x,len; scanf("%s",s); len=(int)strlen(原创 2013-02-22 18:08:55 · 173 阅读 · 0 评论 -
PAT-1012
题目地址:http://pat.zju.edu.cn/contests/pat-a-practise/1012提示:如果分数相同,排名相同。有重复排名是注意排名顺序,是1 2 3 3 5不是1 2 3 3 4。C语言源码:#include#include#include#includetypedef struct student{ int num; int C,E,M原创 2013-02-24 19:20:12 · 317 阅读 · 0 评论 -
PAT-1013
题目地址:http://pat.zju.edu.cn/contests/pat-a-practise/1013C语言源码:#include#include#define maxsize 1010typedef struct node{ int data; struct node *next;}node;node s[maxsize];int visited[maxsize原创 2013-02-25 12:55:45 · 188 阅读 · 0 评论 -
PAT-1015
题目地址:http://pat.zju.edu.cn/contests/pat-a-practise/1015将数字转成指定进制,再反序,判断原数和新数是否都是质数。C语言源码:#include#include#define maxsize 100000int T[maxsize];void pr(){ long long i,j; T[0]=1; T[1]=1;原创 2013-02-25 19:10:45 · 185 阅读 · 0 评论 -
PAT1038-Recover the Smallest Number
题目地址:http://pat.zju.edu.cn/contests/pat-a-practise/1038做的蛋都碎了,一开始自己写的比较函数,老是最后一个Case过不去。后来想了想直接比较字符串,就过了。#include#include#includechar s[10010][10];int cmp(const void *a,const void *b){ ch原创 2013-03-11 13:57:55 · 391 阅读 · 0 评论 -
PAT1027-Colors in Mars
题目地址:http://pat.zju.edu.cn/contests/pat-a-practise/1027C语言源码:#includeint main(){ int a,b,c,i,x; char s[10]; s[7]=0; scanf("%d %d %d",&a,&b,&c); for(i=0;i<7;i++) s[i]='0'; s[0]='#'; i=2;原创 2013-03-23 18:12:17 · 249 阅读 · 0 评论