PAT乙级题解
Cyber_Wz
最近再跟着acwing学算法!会持续更新算法题目见解!大家可以关注我!
展开
-
PAT乙级 1028 人口普查
#include<iostream> #include<string> #include<vector> #include<algorithm> using namespace std; typedef struct{ string name; string bir; }people; bool cmp(people s) { string sx="2014/09/06"; string xx="1814/09/06"; if(s.bir>=.原创 2021-08-13 00:09:44 · 55 阅读 · 0 评论 -
PAT乙级 1026 程序运行时间
#include<iostream> using namespace std; int c1,c2; int main() { cin>>c1>>c2; int ans; ans=(c2-c1+50)/100; printf("%02d:%02d:%02d",ans/3600,ans%3600/60,ans%60); return 0; }原创 2021-08-13 00:09:12 · 53 阅读 · 0 评论 -
PAT乙级 1018 锤子剪刀布
#include<iostream> #include<vector> #include<string> using namespace std; int main() { int N,jwin=0,ywin=0; cin>>N; int k=N; vector<int> v[2];//012 BCJ v[0].resize(3); v[1].resize(3); while(k--) { char a,b; cin>.原创 2021-08-13 00:08:39 · 59 阅读 · 0 评论 -
PAT乙级 1016 部分A+B
#include<iostream> #include<string> using namespace std; int main() { string a,b; int pa,pb,da,db,cnta=0,cntb=0; cin>>a>>da>>b>>db; for(auto i:a) if(i-'0'==da) cnta++; for(auto i:b) if(i-'0'==db) cntb++; if(cn.原创 2021-08-13 00:08:05 · 49 阅读 · 0 评论 -
PAT乙级 1012 数字分类
#include<iostream> #include<vector> #include<algorithm> #include<iomanip> #include<cstdio> using namespace std; int main() { vector<int> a[5]; int N,num,a1=0,a2=0,a5=0; double a4=0.0; cin>>N; while(N--) { .原创 2021-08-13 00:07:21 · 53 阅读 · 0 评论 -
PAT乙级 1011 A+B 和 C
#include<iostream> using namespace std; int main() { long int T,A,B,C; cin>>T; for(int i=1;i<=T;i++){ cin>>A>>B>>C; cout<<"Case #"<<i<<": "<<((A+B)>C?"true":"false")<<endl; } retur.原创 2021-08-13 00:06:40 · 47 阅读 · 0 评论 -
PAT乙级 1010 一元多项式求导
#include<iostream> #include<vector> #include<algorithm> using namespace std; int main() { int M,N,k=0; cin>>M>>N; vector<int> v(M); for(int i=0;i<M;i++) cin>>v[i]; N=N%M; if(N!=0) { reverse(v.begin().原创 2021-08-13 00:05:50 · 73 阅读 · 0 评论 -
PAT乙级 1008 数组元素循环右移问题
#include<iostream> #include<vector> #include<algorithm> using namespace std; int main() { int M,N,k=0; cin>>M>>N; vector<int> v(M); for(int i=0;i<M;i++) cin>>v[i]; N=N%M; if(N!=0) { reverse(v.begin().原创 2021-08-13 00:04:44 · 62 阅读 · 0 评论 -
PAT乙级 1004 成绩排名
#include<iostream> #include<string> #include<vector> #include<algorithm> using namespace std; typedef struct{ string name; string xh; int grade; }stu; struct rule1{ bool operator()(const stu &s1,const stu &s2) const{ .原创 2021-08-13 00:03:52 · 65 阅读 · 0 评论 -
PAT乙级 1001 害死人不偿命的(3n+1)猜想
#include<iostream> using namespace std; int main() { int n,count=0; cin>>n; while(n!=1) { if(n%2==0) n/=2; else n=(3*n+1)/2; count++; } cout<<count; return 0; }原创 2021-08-13 00:02:40 · 64 阅读 · 0 评论