PAT-2021年春季考试-乙级
一共5道题(15,20,20,20,25)
整体不难,挂在了字符串(没看清题)和二分,线性筛上了,还是太菜了。最后一个半小时都在做倒数第二题,还是没做出来。
7-1 打印三角形拼图 (15 分)
正确代码:
#include<iostream>
#include<stdio.h>
using namespace std;
int main(){
int n;
char a,b,c;
while(cin>>n>>a>>b>>c){
for(int i=0;i<n;i++){
for(int j=0;j<n;j++){
if(i==j){
cout<<c;
}
else if(i<j){
cout<<a;
}
else if(i>j){
cout<<b;
}
}
cout<<endl;
}
}
return 0;
}
7-2 赌马 (20 分)
正确代码:
#include<iostream>
#include<stdio.h>
#include<algorithm>
using namespace std;
struct ma{
long long st;
long long et;
long long time;
};
bool cmp(ma a,ma b){
if(a.time!=b.time){
return a.time<b.time;
}
return a.id<b.id;