![](https://img-blog.csdnimg.cn/20201014180756754.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
PAT(basic level)
Alex1777
这个作者很懒,什么都没留下…
展开
-
1011 A+B 和 C (C++)
1没什么好说的,常规的输入输出,值得注意的一点就是,输入参数的取值范围。#include<iostream>using namespace std;int main(){ int n; long a, b, c; cin >> n; for (int i = 0; i < n; i++) { cin >> a >> b >> c; if (a + b > c) cout << "Case .原创 2021-05-24 21:05:21 · 154 阅读 · 0 评论 -
1010 一元多项式求导(C++)
1.未全对#include<iostream>using namespace std;int main(){ int a[2001], n = 0; do { cin >> a[n++]; } while (getchar() != '\n'); for (int i = 0; i < n; i = i + 2) { a[i] = a[i] * a[i + 1]; a[i + 1] = a[i + 1] - 1; } for (int i .原创 2021-05-19 17:03:20 · 186 阅读 · 0 评论 -
1009 反说话(C++)
#include<iostream>#include<string>using namespace std;int main(){ string str[80]; int n = 0; do { cin >> str[n++]; } while (getchar() != '\n'); n--; for (; n >= 0; n--) { printf("%s %c", str[n].c_str(), n ? ' ' : '\n').原创 2021-05-13 19:26:29 · 144 阅读 · 0 评论 -
1008 数组元素循环右移问题 (C++)
方法1:传统循环运动算法#include<iostream>using namespace std;int main(){ int N, M,arr[101],tmp; cin >> N >> M; for (int i = 0; i < N; i++) { cin >> arr[i]; } for (int i = 0; i < M; i++) { tmp = arr[N - 1]; for (int j =.原创 2021-05-06 14:46:17 · 293 阅读 · 0 评论 -
1007 素数对猜想(C++)
#include<iostream>#include<math.h>using namespace std;int main() { int n,j,k=0,m=0,arr[100000]; cin >> n; //找素数 for (int i = 2; i <= n; i++) { for (j = 2; j <= (int)sqrt(i); j++) { if (i % j == 0) break; } .原创 2021-04-28 20:59:29 · 111 阅读 · 0 评论 -
1006 换个格式输出(C++)
#include<iostream>using namespace std;int main(){ int a, b, c,n,tmp; cin >> n; a = n /100; tmp = n % 100; b = tmp/10; tmp %= 10; c = tmp; for (int i = 0; i < a; i++) { cout << "B"; } for (int i = 0; i < b; i++) {.原创 2021-04-28 11:40:34 · 61 阅读 · 0 评论 -
1005继续(3n+1)猜想(C++)
1笨方法没全部正确,不知道为什么,就不贴了。大概思路说一下:就是建立几个数值,将输入值和其覆盖数分别存储,并一一对比,不是关键数的用0赋值,然后排序,输出的时候进行判断,不为0的关键数输出。2利用vector和sort排序#include<iostream>#include<vector>#include<algorithm>using namespace std;int main(){ //vector定义和参数输入 int n,tmp; ci.原创 2021-04-27 21:29:56 · 157 阅读 · 0 评论 -
1004 成绩排名 (C++版)
题目如下#include<iostream>using namespace std;#include<string>//创建学生数据类型:姓名,学会,成绩struct stu{ string name,numb; int score;};int main(){ int n = 0; cin >> n; stu s[10000]; //输入字符串数组 for (int i = 0; i < n; i++) { cin >原创 2021-04-21 10:32:12 · 506 阅读 · 0 评论 -
1003 我要通过!(C++版)
题目如下:#include<iostream>#include<string>using namespace std;int juage(string str){ int n_p = 0, n_t = 0,n_a=0; for (int j = 0; j < str.length(); j++) { //如果某个字符不是P A T三个字符中的一个,返回0 if (str[j] != 'P' && str[j] != 'T' &原创 2021-04-18 11:21:55 · 230 阅读 · 0 评论