随笔分类 - PTA考试真题训练乙级
摘要:// 自己写的还行吧,数组不要忘了开的大一点;#include using namespace std; struct str { string id; int sj; int ks; } s[1010]; int main(){ int n, m, x; cin >> n; for (int i = 0; i > s[i].id >> s[i...
阅读全文
摘要://这道题利用c语言的输入输出才可AC,不然会一直超时#include int main(){ int m, n, a, b, c, k; scanf("%d %d %d %d %d", &m, &n, &a, &b, &c); while (m--){ for (int i = 0; i = a && k <= b) k...
阅读全文
摘要:// 思路是网上以一位大神的,特简单直接采用字符串,判断长度,还有最后一个元素是否T,便可通过ASCll输出数字;#include #include using namespace std; string s; int main(){ while (cin >> s){ if (s.size() == 3 && s[2] == 'T') cou...
阅读全文
摘要:#include #include using namespace std; int main(){ int T, K; cin >> T >> K; while (K--){ int n1, b, t, n2; cin >> n1 >> b >> t >> n2; if (t > T) { //结果的输出前后顺序需要注...
阅读全文
摘要:#include using namespace std; int main(){ int n, A, a, cntA = 0, B, b, cntB = 0; cin >> n; while (n--){ cin >> A >> a >> B >> b; if ((a != A + B && b != A + B) || (a == A...
阅读全文
摘要:#include using namespace std; int arr[100] = {0}; int main(){ int n, m, sum; cin >> n >> m; sum = n * m; if (sum == 0) cout << 0 << endl; else{ int i = 0, flag = ...
阅读全文
摘要:#include #include using namespace std; int main(){ int n; string str; cin >> n; getchar(); while (n--){ int str_num = 0, str_letter = 0, str_dot = 0, str_other = 0; ...
阅读全文
摘要:#include using namespace std; int arr[100100] = {0}; // 大的数组尽量开主函数外面 int main(){ int n, m, x, t; cin >> n; for (int i = 0; i > x; arr[x]++; } cin >> m; for (int i = ...
阅读全文
摘要:#include using namespace std; int main(){ int n, m; char ch; cin >> n >> ch; if (n % 2 == 0) // 行数的奇偶变化 m = n / 2; else m = n / 2 + 1; for (int i = 0; i < ...
阅读全文
摘要:#include #include using namespace std; int main(){ int n, m, max = 1, arr[100005]; cin >> n >> m; for (int i = 0; i > arr[i]; sort(arr, arr + n); for (int j = 0; j = arr[k]){ ...
阅读全文
摘要:#include #include using namespace std; int main(){ int index, arr[10] = {0}; string num; // 一千位的数字很大所以要用字符串进行转化 getline(cin, num); for (int i = 0; i < num.size(); i++){ in...
阅读全文
摘要:#include #include #include using namespace std; int main(){ double sum4 = 0.0; int n, t, k = -1, cnt = 0, cnt2 = 0, max = 0, sum1 = 0, sum2 = 0, sum3 = 0; cin >> n; while (n--){ ...
阅读全文
摘要:#include using namespace std; int main(){ int t; cin >> t; double a, b, c; // 因为int最大是2^31的数字,所以要用double 这个很重要 for (int i = 1; i > a >> b >> c; if (a + b > c) c...
阅读全文
摘要:#include #include #include using namespace std; int main(){ stacks; string str, stu = ""; //制造空字符串 getline(cin, str); for (int i = 0; i < str.size(); i++) { // 通过间接法将一个字符串转入另一个字...
阅读全文
摘要:#include #include #include using namespace std; int main(){ int n, m; cin >> n >> m; int *p = new int[n]; for (int i = 0; i > p[i]; m = m % n; reverse(p, p + n - m); // 算法...
阅读全文
摘要:第一个方法: #include #include using namespace std; int main(){ int n, h, t, o; cin >> n; h = n / 100; // 对于每位数的求解不能出错 t = n / 10 % 10; o = n % 100 % 10; if (h != 0){ // 要使用连续的是那...
阅读全文
摘要:#include using namespace std; struct Stu { int score; string id, num; }stu; int main(){ string s1 ,s2 , s3, s4; int n, max = 0, min = 110; cin >> n; while (n--) { cin...
阅读全文
摘要:#include #include #include using namespace std; int main(){ int sum = 0; string num; stacknumber; string str[10] = {"ling", "yi", "er", "san", "si", "wu", "liu", "qi", "ba", "jiu"}...
阅读全文
摘要:#include using namespace std; int main(){ int n, count = 0; cin >> n; while (n != 1){ if (n % 2 != 0) n = (3 * n + 1) / 2; else n /= 2; co...
阅读全文

浙公网安备 33010602011771号