2021年-PTA天梯赛-L1-6,L1-7,L1-8(无解析)
AcCode:
#include<iostream>
#include<string>
using namespace std;
int main(){
int N, M;
cin >> N >> M;
getchar();
while(N--){
string s;
getline(cin, s);
if(s.find("qiandao") != -1 || s.find("easy") != -1){
continue;
}
if(!M) cout << s;
M--;
}
if(M >= 0) cout << "Wo AK le";
return 0;
}
AcCode:
#include<bits/stdc++.h>
using namespace std;
int main(){
int N;
int max = 0, maxCnt = 0;
int min = 0x7fffffff, minCnt = 0;
cin >> N;
while(N--){
int skil;
cin >> skil;
if(skil <= min){
if(skil != min) minCnt = 0;
min = skil;
minCnt++;
}
if(skil >= max){
if(skil != max) maxCnt = 0;
max = skil;
maxCnt++;
}
}
cout << min << " " << minCnt << endl << max << ' ' << maxCnt;
return 0;
}
这题有段错误的试试数据
0 3 10
AcCode:
#include<bits/stdc++.h>
using namespace std;
vector<int> res;
stack<int> s;
void fun(int a1, int a2){
int sum = a1 * a2;
if(sum == 0){
res.push_back(0);
return ;
}
while(sum){
s.push(sum % 10);
sum /= 10;
}
while(!s.empty()){
res.push_back(s.top());
s.pop();
}
}
int main(){
int a1, a2, n, idx1 = 0, idx2 = 1;
cin >> a1 >> a2 >> n;
res.push_back(a1);
res.push_back(a2);
while(res.size() <= n){
fun(res[idx1++], res[idx2++]);
}
for(int i = 0; i < n; i++){
cout << res[i];
if(i != n - 1) cout << " ";
}
return 0;
}
顺便把代码块样式代码更新了一下。。要不然太小了