Coder

舒心、快乐,比什么都重要

随笔分类 -  PTA考试真题训练乙级

摘要:#include #include #include using namespace std; setss; void tmp() { int n, m, t; cin >> t >> n >> m; for (int i = 1; i > s; if (i == m && ss.count(s) == 0) { // count() 用来查... 阅读全文
posted @ 2019-05-01 00:55 H123K 阅读(422) 评论(0) 推荐(0)
摘要:#include #include using namespace std; int main() { string num; int a, b, m; cin >> num >> m; // 一个为字符串一个为整形数字避免了麻烦的处理 int len = num.size(); a = (num[0] - '0') / m; b ... 阅读全文
posted @ 2019-05-01 00:02 H123K 阅读(177) 评论(0) 推荐(0)
摘要:#include using namespace std; int main() { int n; string s1, s2; getline(cin,s1); getline(cin,s2); int a[128] = {0}; // 建立一个128的字符的数组 for (int i = 0; i < s1.length(); i++)... 阅读全文
posted @ 2019-04-30 21:33 H123K 阅读(187) 评论(0) 推荐(0)
摘要:#include #include #include using namespace std; struct s { string id; int dis; } num[10010]; // 结构体数组变量开的大一点 bool cmp (s a, s b) { // 形参中用结构体定义两个结构体变量 return a.dis > n; for (int... 阅读全文
posted @ 2019-04-30 00:09 H123K 阅读(109) 评论(0) 推荐(0)
摘要:// 建一个判断函数,接受两个整形的变量,再通过循环按位判断相等与否,主体函数中调用被调函数,建立一个判断变量。#include using namespace std; bool cmp (int x, int k) { while (k != 0) { int t1 = x % 10; int t2 = k % 10; if (t1... 阅读全文
posted @ 2019-04-29 20:03 H123K 阅读(237) 评论(0) 推荐(0)
摘要:#include #include // set 集合中没有重复的元素 using namespace std; int cmp(int t) { int sum = 0; while (t != 0) { sum += t % 10; t /= 10; } return sum; } int main() { in... 阅读全文
posted @ 2019-04-29 08:49 H123K 阅读(114) 评论(0) 推荐(0)
摘要:#include #include using namespace std; int main() { int n, i, sum = 0, cnt = 0; // 这是为零很重要 string s; int w[17] = { 7,9,10,5,8,4,2,1,6,3,7,9,10,5,8,4,2 }; char z[11] = { '1', '0', '... 阅读全文
posted @ 2019-04-26 12:57 H123K 阅读(455) 评论(0) 推荐(0)
摘要:// 首先创建一个结构体,再创建三个结构体变量,设定好边界,记录合格人数,进行比较,输出。#include #include using namespace std; struct s { string name, bir; } a, young, old; int main() { int n, cnt = 0; string down = "1814/09/06... 阅读全文
posted @ 2019-04-24 21:03 H123K 阅读(384) 评论(0) 推荐(0)
摘要:#include #include #include using namespace std; int arr[1 > n; for (int i = 1; i > x; arr[x] = i; } cin >> m; while (m--) { cin >> y; if (arr[y] == -1) { //... 阅读全文
posted @ 2019-04-24 01:23 H123K 阅读(185) 评论(0) 推荐(0)
摘要:#include #include using namespace std; int arr[1 > n; for (int i = 1; i > x; t = abs(x - i); arr[t]++; } for (int i = 10000; i >= 0; i--) { if (arr[i] > 1) {. //... 阅读全文
posted @ 2019-04-24 00:39 H123K 阅读(189) 评论(0) 推荐(0)
摘要:#include #include using namespace std; int main() { int n, m; cin >> n >> m; for (int i = 0; i > g2; for (int j = 0; j > x; if (x >= 0 && x <= m) { s... 阅读全文
posted @ 2019-04-24 00:13 H123K 阅读(162) 评论(0) 推荐(0)
摘要:// 思路就是用一维数组输入的同时将数据存到向量中,然后对其进行排序,下一步再将数组与向量的数字进行一一匹配,匹配到的一样的次数就是主元的数量,不匹配的特殊标记,最后通过小技巧输出行末不得有空格的情况,最后的那个换行不能忘,不然过不了。#include #include #include using namespace std; const int maxn = 20; int arr[1... 阅读全文
posted @ 2019-04-23 22:02 H123K 阅读(147) 评论(0) 推荐(0)
摘要:#include #include using namespace std; int main() { char c; int g1, g2, s1, s2, k1, k2; cin >> g1 >> c >> s1 >> c >> k1; cin >> g2 >> c >> s2 >> c >> k2; int p1 = g1 * 17 * 29 +... 阅读全文
posted @ 2019-04-23 21:28 H123K 阅读(188) 评论(0) 推荐(0)
摘要:#include #include using namespace std; int n, x, y; // 这样就可以很灵活 void print(double t) { if (n == t) cout > n >> x >> y; for (int a = 99; a >= 10; a--) { int b = a % 10 * 10... 阅读全文
posted @ 2019-04-23 13:20 H123K 阅读(235) 评论(0) 推荐(0)
摘要:#include #include int main() { int n; scanf("%d", &n); // 之前一直用c++过不了,因为会有空格的关系,所以改用了scanf; while (n--) { char s[110]; int np = 0, lp = 0, nt = 0, lt = 0, other = 0; ... 阅读全文
posted @ 2019-04-22 21:54 H123K 阅读(320) 评论(0) 推荐(0)
摘要:// 这道题运用的小技巧很多#include #include #include using namespace std; bool cmp (char a, char b) { // 用来递减排序 return a > b; } int main() { string num; cin >> num; num.insert(0, 4 - num.siz... 阅读全文
posted @ 2019-04-22 20:18 H123K 阅读(236) 评论(0) 推荐(0)
摘要://自己写的很长,这是参考的网上以为大牛的;#include #include using namespace std; int main() { int n, y, wina = 0, winb = 0, a[3] = {0}, b[3] = {0};; char s, t; cin >> n; y = n; while (n--) { ... 阅读全文
posted @ 2019-04-22 16:29 H123K 阅读(174) 评论(0) 推荐(0)
摘要:#include #include using namespace std; int main() { int m, n, i = 2, cnt = 0; bool isnum; cin >> m >> n; while (cnt != n) { isnum = true; for (int j = 2; j = m && cn... 阅读全文
posted @ 2019-04-22 15:12 H123K 阅读(169) 评论(0) 推荐(0)
摘要:// 题目不难,感觉变量定义的有点儿多了#include #include using namespace std; int main(){ int i = 0, j = 0, ta = 0, tb = 0, suma = 0, sumb = 0; int A, Da, Pa, B, Db, Pb; cin >> A >> Da >> B >> Db; whi... 阅读全文
posted @ 2019-04-21 22:20 H123K 阅读(153) 评论(0) 推荐(0)
摘要:#include using namespace std; const int maxn = 20; // const 不能忘,新学的技能 int arr[1 > n >> m; for (int i = 0; i > arr[i]; } for (int j = 0; j > brr[j]; } int x, sum; while (n--)... 阅读全文
posted @ 2019-04-21 21:58 H123K 阅读(137) 评论(0) 推荐(0)