算法竞赛入门经典(第二版)-刘汝佳-第三章 数组与字符串 例题+习题(17/18)

2023-05-16

文章目录

  • 说明
  • 例题
    • 例3-1 UVA 272 TeX 中的引号
    • 例3-2 UVA 10082 WERTYU
    • 例3-3 UVA 401 回文词
    • 例3-4 UVA 340 猜数字游戏的提示
    • 例3-5 UVA 1583 生成元
    • 例3-6 UVA 1584 环状序列
    • 习3-1 UVA 1585 得分
    • 习3-2 UVA 1586 分子量
    • 习3-3 UVA 1225 数数字
    • 习3-4 UVA 455 周期串
    • 习3-5 UVA 227 谜题
    • 习3-6 UVA 232 纵横字谜的答案
    • 习3-7 UVA 1368 DNA 序列
    • 习3-8 UVA 202 循环小数
    • 习3-9 UVA 10340 子序列
    • 习3-10 UVA 1587 盒子
    • 习3-11 UVA 1588 换低档装置
    • 习3-12 UVA 11809 浮点数(未通过)

说明

本文是我对第三章题目的练习总结,建议配合紫书——《算法竞赛入门经典(第2版)》阅读本文。
另外为了方便做题,我在VOJ上开了一个contest,欢迎一起在上面做:第三章contest
如果想直接看某道题,请点开目录后点开相应的题目!!!

例题

例3-1 UVA 272 TeX 中的引号

思路
这个题主要讲带空格的输入输出处理。我总结了一下,主要有三种方案:
1、用getchar()一个一个字符处理
2、用fgets读入(gets已经过时)
3、用getline读入
代码

#include <iostream>
#include <cstdio>
#include <algorithm>
using namespace std;

int main(void)
{
    char c;
    bool flag = true;
    while ((c = getchar()) != EOF) {
        if (c == '\"') {
            printf("%s", flag ? "``" : "''");
            flag = !flag;
        } else
            printf("%c", c);
    }

    return 0;
}

例3-2 UVA 10082 WERTYU

思路
常量数组的妙用,可以使程序简洁很多。
代码

#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;

char s[] = "`1234567890-=QWERTYUIOP[]\\ASDFGHJKL;'ZXCVBNM,./";

int main(void)
{
    char c;
    while ((c = getchar()) != EOF) {
        char *p = strchr(s, c);
        if (!p) putchar(c);
        else putchar(s[p-s-1]);
    }

    return 0;
}

例3-3 UVA 401 回文词

思路
常量字符串和字符串数组的妙用,使程序更简洁。
另外,学习了strchr函数,主要功能是在字符串中查找字符,返回字符指针。
代码

#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;

const char mirror[] = "A   3  HIL JM O   2TUVWXY51SE Z  8 ";
const char *msg[4] = {" -- is not a palindrome.",
    " -- is a regular palindrome.",
    " -- is a mirrored string.",
    " -- is a mirrored palindrome."};

char trans(char c)
{
    if (c <= '9') return mirror[c - '0' + 25];
    return mirror[c - 'A'];
}

int main(void)
{
    char s[30];
    while (cin >> s) {
        int p = 1, m = 1;
        int n = strlen(s);
        for (int i = 0; i <= n/2; i ++) {
            if (s[i] != s[n-1-i]) p = 0;
            if (trans(s[i]) != s[n-1-i]) m = 0;
        }
        printf("%s%s\n\n", s, msg[m*2+p]);
    }

    return 0;
}

例3-4 UVA 340 猜数字游戏的提示

思路
当数值范围较小时,可以用统计数组。我这里判断正确值和错误值的方式与例题稍有不同,思路大同小异。
代码

#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;

const int N = 1000;
const int M = 10;

int n, a0[N], c0[M], c2[M];
int a1[N], c1[M];

int main(void)
{
    int t = 0;
    while (cin >> n && n) {
        memset(c0, 0, sizeof(c0));
        for (int i = 0; i < n; i ++) {
            scanf("%d", &a0[i]);
            c0[a0[i]]++;
        }

        printf("Game %d:\n", ++t);
        while (true) {
            int flag = false;
            int cntA = 0, cntB = 0;
            memcpy(c2, c0, sizeof(c0));
            memset(c1, 0, sizeof(c1));
            for (int i = 0; i < n; i ++) {
                scanf("%d", &a1[i]);
                if (a1[i]) flag = true;
                c1[a1[i]]++;
                if (a1[i] == a0[i]) {
                    cntA ++;
                    c2[a0[i]] --;
                    c1[a0[i]] --;
                }
            }
            if (flag == false)
                break;
            for (int i = 1; i < M; i ++)
                if (c2[i]) cntB += min(c1[i], c2[i]);
            printf("    (%d,%d)\n", cntA, cntB);
        }
    }

    return 0;
}

例3-5 UVA 1583 生成元

思路
当计算过程复杂而且对结果有多次查询时,就应当考虑将计算结果保存成表,从而大大提高查询效率。
这是本题的主要思想。
代码

#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;

const int N = 100000;

int main(void)
{
    int n, a[N+1];
    memset(a, 0, sizeof(a));
    for (int i = 1; i < N; i ++) {
        int m = i, sum = 0;
        while (m) { sum += m%10; m /= 10;}
        n = sum + i;
        if (n <= N && a[n] == 0) a[n] = i;
    }

    int t;
    cin >> t;
    while (t--) {
        cin >> n;
        printf("%d\n", a[n]);
    }

    return 0;
}

例3-6 UVA 1584 环状序列

思路
此题考查字符串排序。我的做法与书中不同,我是将长度为n字符串s复制一份连接到它的后面成为s2,这样环状序列的所有表示就是s2中所有长度为n的子字符串,用strncmp比较即可。
书中做法和我的方法都避免了n次字符串复制操作。
代码

#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;

const int N = 100;

int main(void)
{
    int t, n;
    char s0[2*N+1], s1[2*N+1];

    cin >> t;
    while (cin >> s0) {
        n = strlen(s0);
        strcpy(s1, s0);
        strcat(s0, s1);
        strcpy(s1, s0);
        int mi = 0;
        for (int i = 0; i < n; i ++) {
            if (strncmp(s0+mi, s1+i, n) > 0)
                mi = i;
        }
        strncpy(s1, s0+mi, n);
        s1[n] = '\0';
        printf("%s\n", s1);
    }

    return 0;
}

#习题

习3-1 UVA 1585 得分

思路
用add变量记录当前的O字符连续出现的个数,遇到X清零。
代码

#include <iostream>
#include <cstdio>
#include <algorithm>
using namespace std;

int main(void)
{
    int t;
    char s[81];

    cin >> t;
    while (t--) {
        scanf("%s", s);
        int add = 0, sum = 0;
        for (int i = 0; s[i]; i ++) {
            if (s[i] == 'O') {
                add ++;
                sum += add;
            } else
                add = 0;
        }
        printf("%d\n", sum);
    }

    return 0;
}

习3-2 UVA 1586 分子量

思路
考察基本的输入分析,可以先读入整个字符串然后分析。
代码

#include <iostream>
#include <cstdio>
#include <algorithm>
using namespace std;

const char name[] = "CHON";
double weight[] = {12.01, 1.008, 16.00, 14.01};

int main(void)
{
    int t;
    char s[81];

    cin >> t;
    while (t--) {
        scanf("%s", s);
        int num;
        double sum = 0;
        int i = 0;
        while (s[i]) {
            int j;
            for (j = 0; j < 4; j ++) {
                if (s[i] == name[j]) break;
            }
            i ++;
            num = 1;
            if (isdigit(s[i])) num = (s[i++]-'0');
            if (isdigit(s[i])) num = num*10 + (s[i++]-'0');
            sum += num * weight[j];
        }
        printf("%.3lf\n", sum);
    }

    return 0;
}

习3-3 UVA 1225 数数字

思路
这个题暴力搜索也能过,因为数据范围太小。但这样就失去了意义。
我用函数写的,具有较强的普适性。主要思想是对每一位分别分析——当前位、高位、低位分别为指定数字——情况下的数的个数。
代码

#include <iostream>
#include <cstdio>
#include <algorithm>
using namespace std;

int cnt(int n, int x)
{
    int res = 0;
    int fact = 1, high = n/10, crt = n%10, low = 0;
    while (high || (x && crt >= x)) {
        //printf("%d %d %d %d\n", fact, high, crt, low);
        res += high*fact;
        if (x == 0) res -= fact;
        if (crt > x) res += fact;
        if (crt == x) res += (low+1);
        low += fact*crt;
        crt = high%10;
        high /= 10;
        fact *= 10;
    }
    return res;
}


int main(void)
{
    int t, n;
    cin >> t;
    while (t --) {
        cin >> n;
        for (int i = 0; i < 10; i ++) {
            printf("%d%c", cnt(n, i), i == 9 ? '\n' : ' ');
        }
    }

    return 0;
}

习3-4 UVA 455 周期串

思路
字符串的周期一定是长度的约数,根据这个进行枚举就可以了。
代码

#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
using namespace std;

int main(void)
{
    int t;
    char s[81];

    cin >> t;
    while (t --) {
        scanf("%s", s);
        int i;
        int n = strlen(s);
        for (i = 1; i <= n; i ++) {
            if (n % i) continue;
            bool flag = true;
            for (int j = 1; j < n/i; j ++) {
                for (int k = 0; k < i; k ++) {
                    if (s[k] != s[k+j*i]) {
                        flag = false; break;
                    }
                }
                if (flag == false) break;
            }
            if (flag == true) break;
        }
        printf("%d\n", i);
        if (t) printf("\n");
    }

    return 0;
}

习3-5 UVA 227 谜题

思路
这个题我用了两个常量数组,inst数组的作用是将字符翻译成方向数组对应的下标(0-3),方向数组dir的作用是表示四个方向x和y坐标的变化。这样一个循环就ok了,不需要4个方向重复写4次代码。
另外注意最后一组数据后面没有空行,UVA很多题目都要求这样输出。
代码

#include <iostream>
#include <cstdio>
#include <algorithm>
using namespace std;

const char inst[] = "ABLR";
const int dir[4][2] = {{-1, 0}, {1, 0}, {0, -1}, {0, 1}};

int main(void)
{
    int t = 0;
    char s[5][6];
    char c;
    while ((s[0][0] = getchar()) != 'Z') {
        int bi = 0, bj = 0;
        for (int i = 0; i < 5; i ++) {
            for (int j = 0; j < 5; j ++) {
                if (!i && !j) continue;
                s[i][j] = getchar();
                if (s[i][j] == ' ') {bi = i, bj = j;}
            }
            getchar();
        }
        bool legal = true;
        while ((c = getchar()) != '0') {
            if (legal == false || c == '\n') continue;
            int k;
            for (k = 0; k < 4; k ++) {
                if (c == inst[k]) break;
            }
            if (k == 4)
                legal = false;
            else {
                int ni = bi+dir[k][0], nj = bj+dir[k][1];
                if (0 <= ni && ni < 5 && 0 <= nj && nj < 5) {
                    swap(s[bi][bj], s[ni][nj]);
                    bi = ni, bj = nj;
                } else
                    legal = false;
            }
        }
        if (++t > 1) printf("\n");
        printf("Puzzle #%d:\n", t);
        if (legal == false)
            printf("This puzzle has no final configuration.\n");
        else {
            for (int i = 0; i < 5; i ++) {
                for (int j = 0; j < 5; j ++) {
                    printf("%c%c", s[i][j], j == 4 ? '\n' : ' ');
                }
            }
        }
        getchar();
    }

    return 0;
}

习3-6 UVA 232 纵横字谜的答案

思路
因为需要编号,应当先扫描并保存起始格的位置,然后分别输出横向和纵向的单词。
代码

#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;

const int N = 10;

int main(void)
{
    int t = 0;
    int n, m;
    char s[N][N+1];
    int cnt = 0;
    int pos[N*N+1][2];
    while (scanf("%d", &n) != EOF && n) {
        scanf("%d", &m);
        getchar();
        cnt = 0;
        memset(pos, 0, sizeof(pos));
        for (int i = 0; i < n; i ++) {
            for (int j = 0; j < m; j ++) {
                s[i][j] = getchar();
                if (s[i][j] == '*') continue;
                if (i == 0 || j == 0 || s[i-1][j] == '*' || s[i][j-1] == '*') {
                    pos[cnt][0] = i, pos[cnt][1] = j;
                    cnt ++;
                }
            }
            getchar();
        }

        if (t > 0) printf("\n");
        printf("puzzle #%d:\n", ++t);
        printf("Across\n");
        for (int k = 0; k < cnt; k ++) {
            int i = pos[k][0], j = pos[k][1];
            if (j > 0 && s[i][j-1] != '*') continue;
            printf("%3d.", k+1);
            do {
                printf("%c", s[i][j]);
                j ++;
            } while (j < m && s[i][j] != '*');
            printf("\n");
        }
        printf("Down\n");
        for (int k = 0; k < cnt; k ++) {
            int i = pos[k][0], j = pos[k][1];
            if (i > 0 && s[i-1][j] != '*') continue;
            printf("%3d.", k+1);
            do {
                printf("%c", s[i][j]);
                i ++;
            } while (i < n && s[i][j] != '*');
            printf("\n");
        }
    }

    return 0;
}

习3-7 UVA 1368 DNA 序列

思路
找出每列中ACGT出现次数最多的字符,就是最优解序列在这一列的字符值。另外注意要求的是字典序最小的解。
代码

#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;

const int N = 1000;
const int M = 50;
char *DNA = "ACGT";

int main(void)
{
    int m, n;
    char s[M][N+1];
    int cnt[N][4];
    int ans[N];
    int d;

    int t;
    cin >> t;
    while (t --) {
        cin >> m >> n;
        for (int i = 0; i < m; i ++)
            scanf("%s", s[i]);

        memset(cnt, 0, sizeof(cnt));
        for (int i = 0; i < m; i ++) {
            for (int j = 0; j < n; j ++) {
                cnt[j][strchr(DNA, s[i][j]) - DNA] ++;
            }
        }
        memset(ans, 0, sizeof(ans));
        d = 0;
        for (int j = 0; j < n; j ++) {
            for (int k = 0; k < 4; k ++) {
                if (cnt[j][k] > cnt[j][ans[j]])
                    ans[j] = k;
            }
            for (int k = 0; k < 4; k ++)
                if (k != ans[j]) d += cnt[j][k];
        }

        for (int j = 0; j < n; j ++)
            putchar(DNA[ans[j]]);
        printf("\n%d\n", d);
    }

    return 0;
}

习3-8 UVA 202 循环小数

思路
求循环节需要模拟循环小数的求解过程。那么什么时候会出现循环呢?在除的过程中,除数b是不变的,而被除数a一直在变化,那么当a变换为之前出现过的某个值时,就出现了循环。
代码

#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
using namespace std;

const int N = 3000;

int main(void)
{
    int a, b;
    while (scanf("%d%d", &a, &b) != EOF) {
        printf("%d/%d = %d.", a, b, a/b);
        a %= b;
        int n = 0;;
        int dec[N+1];
        int arr[N+1];
        bool used[N+1] = {0};
        while (!used[a]) {
            arr[n] = a;
            used[a] = 1;
            a *= 10;
            dec[n] = a/b;
            n++;
            a %= b;
        }
        int m = 0;
        for (m = 0; m < n; m++) {
            if (arr[m] == a) break;
        }

        for (int i = 0; i < m; i++)
            printf("%d", dec[i]);
        printf("(");
        for (int i = m; i < n && i < m+50; i++)
            printf("%d", dec[i]);
        int len = n - m;
        if (len > 50) printf("...");
        printf(")\n   %d = number of digits in repeating cycle\n\n", len);
    }

    return 0;
}

习3-9 UVA 10340 子序列

思路
顺序扫描t中字符,遇到与s首字符相同情况即删除s首字符,同时继续往前扫描。当s中字符空时,说明t删除字符可以得到s。
代码

#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
using namespace std;

int main(void)
{
    string s1, s2;
    while (cin >> s1 >> s2) {
        int i = 0;
        for (int j = 0; j < s2.size(); j ++) {
            if (s1[i] == s2[j]) i++;
            if (i == s1.size()) break;
        }
        printf("%s\n", i == s1.size() ? "Yes" : "No");
    }

    return 0;
}

习3-10 UVA 1587 盒子

思路
这种题目看似简单,但不好写标准统一的代码,而且容易漏掉一些细节而出错。我建议尽量将代码标准化,减少失误的可能。有同学用类的思想处理,有值得借鉴之处。
代码

#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;

int main(void)
{
    int a[12];
    while (scanf("%d%d", &a[0], &a[1]) != EOF) {
        if (a[0] > a[1]) swap(a[0], a[1]);
        for (int i = 2; i < 12; i += 2) {
            scanf("%d%d", &a[i], &a[i+1]);
            if (a[i] > a[i+1]) swap(a[i], a[i+1]);
        }
        int b[12];
        memcpy(b, a, sizeof(a));
        sort(a, a+12);

        bool flag = true;
        int n[3];
        for (int i = 0; i < 3; i ++) {
            n[i] = a[i*4];
            for (int j = 1; j < 4; j ++) {
                if (n[i] != a[i*4+j])
                    flag = false;
            }
        }

        int m[3] = {0};
        for (int i = 0; i < 12; i += 2) {
            if (m[0] < 2 && b[i] == n[0] && b[i+1] == n[1]) m[0] ++;
            else if (m[1] < 2 && b[i] == n[0] && b[i+1] == n[2]) m[1] ++;
            else if (m[2] < 2 && b[i] == n[1] && b[i+1] == n[2]) m[2] ++;
            else flag = false;
        }
        if (! (m[0] == 2 && m[1] == 2) )
            flag = false;
        //printf("%d %d %d\n", m[0], m[1], m[2]);

        if (flag)
            printf("POSSIBLE\n");
        else
            printf("IMPOSSIBLE\n");
    }

    return 0;
}

习3-11 UVA 1588 换低档装置

思路
此题同上题一样,在标准化方面有一定困难。我一开始写的程序能通过用例,但死活就一直WA。
这段代码是参考别人的写的,其代码比较规范,值得推荐。
代码

#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;

char s1[110], s2[110];

int test(int k, char s1[], char s2[]) {
    for (int i = 0; s1[k+i] && s2[i]; i++)
      if (s1[k+i]+s2[i]-2*'0' > 3) return 0;
    return 1;
}

int fun(char s1[], char s2[]) {
    int k = 0;
    while (!test(k, s1, s2)) k++;
    return max(strlen(s1), strlen(s2)+k);
}

int main() {
    while (scanf("%s%s", s1, s2) != EOF) {
        printf("%d\n", min(fun(s1, s2), fun(s2, s1)));
    }
    return 0;
}

习3-12 UVA 11809 浮点数(未通过)

思路
我的做法是根据最大十进制数反推二进制表示中的M和E,例子都过了,但是提交后TLE。搜了一下其他人的解法,清一色的打表。这个题的M和E范围确实有限,打表只需要预先计算300个并保存,然后查表即可。
估计这个题的查询量比较大吧,否则我直接求应该也可以的。
有时间重新写一个打表的程序把这题AC掉,先贴上我的TLE代码。看到本文的大神如有指导也请不吝赐教。
代码

#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<cmath>
using namespace std;

const double EPS = 1e-6;

int main()
{
    double a;
    while (scanf("%lf", &a) != EOF) {
        if (abs(a) < EPS) break;
        int y = 0;
        while (a >= 1) {
            a /= 2;
            y++;
        }

        int m = 0;
        a = 1-a;
        while (abs(a-1) > EPS) {
            a = a*2;
            m ++;
        }

        int e = 0;
        while (y) {
            e++;
            y /= 2;
        }

        printf("%d %d\n", m-1, e);
    }

    return 0;
}

----------)

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

算法竞赛入门经典(第二版)-刘汝佳-第三章 数组与字符串 例题+习题(17/18) 的相关文章

  • (struct)结构体变量作为函数参数调用的方法小结

    结构体变量 结构指针变量 结构数组作为函数的参数应用实例分析 struct stud long int num float score 结构体变量作为函数的参数 xff0c 修改之后的成员值不能返回到主调函数 void funvr stru
  • 搭建nginx反向代理用做内网域名转发

    基于域名的7层转发的实现 xff08 NAT 43 反向代理 xff09 在实际办公网中 xff0c 因为出口IP只有一个 xff0c 要实现对外提供服务的话就必须得做端口映射 xff0c 如果有多个服务要对外开放的话 xff0c 这只能通
  • 从平面上最近的点对,谈谈分治算法

    首先介绍一下分治 xff08 Divide and Conquer xff09 算法 xff1a 设计过程分为三个阶段 Divide xff1a 整个问题划分为多个子问题 Conquer xff1a 求解各子问题 递归调用正设计的算法 Co
  • NOIP2017 国庆郑州集训知识梳理汇总

    第一天 基础算法及数学 基本算法 递推 递归 分治 二分 倍增 贪心 递推 指通过观察 归纳 xff0c 发现较大规模问题和较小规模问题之间的关系 xff0c 用一些数学公式表达出来 在一些题解中 xff0c 和 计数DP 是指同一个概念
  • 挑战程序设计竞赛 — 知识总结

    准备篇 1 5 运行时间 概述编写的目的是面向ACM程序设计竞赛 xff0c 不可避免的要涉及复杂度和运行时间的问题 xff0c 本节给出了解决问题算法选择的依据 假设题目描述中给出的限制条件为n lt 61 1000 xff0c 针对O
  • 阿里巴巴笔试题选解

    阿里巴巴笔试题选解 9月22日 xff0c 阿里巴巴北邮站 小题 xff1a 1 有三个结点 xff0c 可以构成多少种二叉树形结构 xff1f 2 一副牌52 张 去掉大小王 xff0c 从中抽取两张牌 xff0c 一红一黑的概率是多少
  • 腾讯2014软件开发笔试题目

    腾讯2014软件开发笔试题目 9月21日 xff0c 腾讯2014软件开发校招 简答题 广州 简答题 xff1a 1 请设计一个排队系统 xff0c 能够让每个进入队伍的用户都能看到自己在 中所处的位置和变化 队伍可能随时有人加入和退出 x
  • MAVLink简介

    MAVLink简介 Mavlink协议最早由 苏黎世联邦理工学院 计算机视觉与几何实验组 的 Lorenz Meier于2009年发布 xff0c 并遵循LGPL开源协议 Mavlink协议是在串口通讯基础上的一种更高层的开源通讯协议 xf
  • C/C++ 服务器程序(从入门到精通)

    Windows 服务被设计用于需要在后台运行的应用程序以及实现没有用户交互的任务 为了学习这种控制台应用程序的基础知识 xff0c C xff08 不是C 43 43 xff09 是最佳选择 本文将建立并实现一个简单的服务程序 xff0c
  • 图像处理常用算法(C++/OPENCV)

    添加椒盐噪声 void salt Mat amp src int number for int i 61 0 i lt number i 43 43 int r 61 static cast lt int gt rng uniform 0
  • 【解决linux下连接向日葵失败或连接之后断开的解决方案】

    解决linux下连接向日葵失败或连接之后断开的解决方案 linux在软件中搜索lightdm桌面管理器并安装即可 xff01
  • 机器学习推荐系统评价指标之AUC

    机器学习推荐系统评价指标之AUC 综述AUC的计算过程AUC的优势 综述 AUC是机器学习模型中常见评价指标 xff0c 在推荐系统中也十分常见 和常见的评价指标Acc xff0c P xff0c R相比 xff0c AUC具备一定的优势
  • 多线程访问同步方法情况

    文章目录 1 多线程访问同步方法1 1 两个线程同时访问一个对象的同步方法1 1 1 代码演示1 1 2 运行结果 1 2 两个线程访问的是两个对象的同步方法1 2 1 代码演示1 2 2 运行结果 1 3 两个线程访问的是synchron
  • 剑指 Offer 33. 二叉搜索树的后序遍历序列

    题目描述 xff1a 输入一个整数数组 xff0c 判断该数组是不是某二叉搜索树的后序遍历结果 如果是则返回 true xff0c 否则返回 false 假设输入的数组的任意两个数字都互不相同 参考以下这颗二叉搜索树 xff1a 5 2 6
  • 求解空间两个三维坐标系之间的变换矩阵

    三维刚体变换模型 即旋转 平移矩阵 RT矩阵 的估计方法 原理简单阐述 只要算出变换矩阵 就可以算出A坐标系的一个点P在坐标系B里的对应点坐标 即 T为3x3的转换矩阵 t 为3x1的位移变换向量 这里点坐标均为3x1的列向量 非齐次形式
  • Ubuntu下网络调试助手 NetAssist

    近期在ubuntu下开发一个网络相关的程序 之前在windows上开发时 xff0c 一直使用NetAssist这个小工具 xff0c 简洁实用 所以就安装了一个对应版本的网络调试助手 NetAssist 下载地址 xff1a 链接 xff
  • 程序员裸辞三个月,终于拿到大厂offer!网友:不应该!

    一个行业发展成熟 xff0c 必定会重新洗牌 xff0c 就像朝代的更替一样 xff0c 现在互联网发展就是遇到了这样的瓶颈期 xff0c 出现了衰退 xff0c 就形成大家口中所说的 互联网寒冬 但是有技术的人哪里怕过寒冬 xff0c 所
  • HttpUtils 用于进行网络请求的工具类

    用于进行网络请求的工具类 xff0c 可进行get xff0c post两种请求 xff0c 值得一提的是这个utils给大家提供了一个回调接口 xff0c 方便获取下载文件的进度 span class hljs keyword impor
  • deepin系统

    https www uc23 net xinwen 76259 html 据介绍 xff0c 深度操作系统 xff08 deepin xff09 自 2015 年开始 xff0c 就放弃基于 Ubuntu 作为上游 xff0c 选择 Ubu
  • 学习日志2

    这几天一直在思考如何解决摄像头与vins与fast planner如何相结合再应用的问题 因为摄像头是因特尔的D435i xff0c 于是决定在gazebo上实现D435i的仿真 由于D435I版本较新 xff0c 因此github上基本没

随机推荐

  • 学习日志3

    这几天准备用分别用ego planner与fast planner进行飞行仿真 本来准备在双系统的ubuntu上安装ego planner xff08 之前ubuntu上已经安装过vins fusion vins mono与fast pla
  • 学习日志5

    最近老师让我阅读了一篇新文章 xff0c 文章标题如下图 文章通过解决时间分配问题以及通过模型预测轮廓同时控制问题控制 xff08 MPCC xff09 优化能够使四旋翼无人机找到最优轨迹 xff0c 可以快速地避障 xff0c 速度甚至可
  • 万字长文 | 阿里大佬 ssp offer 的后台服务器开发学习路线

    前言 小北去年经历春秋招 xff0c 拿到了不少大厂 offer xff0c 其中包括 sp ssp 等 xff0c 感觉在复习准备校招上还是有一定方法的 xff0c 因为我自己是 Linux C C 43 43 路线 所以这一篇的主题是
  • 看完谷歌大佬的刷题笔记, 我直接手撕了200道 Leetcode 算法题

    如果你刷leetcode觉得吃力 那么一定需要这份谷歌大佬的leetcode刷题笔记 在这里推荐一个谷歌大佬的刷题笔记 每一道题的题解都写得非常清楚 作者在美国卡内基梅隆大学攻读硕士学位时 xff0c 为了准备实习秋招 xff0c 他从夏天
  • JVM中的栈区域

    一 栈 xff1a 在JVM中也叫栈内存 xff0c 主要负责java程序的运行 xff0c 栈在线程创建时被创建 xff0c 栈时线程私有的 xff0c 也即每一个线程都有自己的栈空间 xff0c 线程之间的运行不受影响 相互独立 二 栈
  • 初步认识ADRC(自抗扰控制)与应用

    这是一个目录 ADRC的基本原理一 参考资料推荐二 为什么PID好 xff0c 以及 xff0c 为什么PID不够好1 为什么PID好 不依赖于模型的控制器2 为什么PID不够好 PID的缺点 三 ADRC给出的方案 如何保留PID的优点
  • 先进非线性控制方法 INDI 快速部署到PX4用于四旋翼控制(part2)

    目录 一 PX4 v11 的姿态控制解析1 角度环控制2 角速度环控制3 控制分配 二 简易INDI如何部署到PX41 获取角加速度 和 电机转速测量值 xff08 1 xff09 角加速度 xff08 2 xff09 转速 2 具体实现过
  • ubuntu18.04 cv2.VideoCapture无法读取视频

    源代码 xff1a span class token comment 读取视频 span span class token keyword import span cv2 video file span class token operat
  • 关于字符串结束标志‘\0‘的一些见解

    前言 本人是一个刚刚上路的IT新兵 菜鸟 分享一点自己的见解 如果有错误的地方欢迎各位大佬莅临指导 如果这篇文章可以帮助到你 劳请大家点赞转发支持一下 一 39 0 是什么 xff1f 0 是转义字符 xff0c 为了告诉编译器 0 是空字
  • gRPC 基础(二)-- Go 语言版 gRPC-Go

    gRPC Go Github gRPC的Go实现 一个高性能 开源 通用的RPC框架 xff0c 将移动和HTTP 2放在首位 有关更多信息 xff0c 请参阅Go gRPC文档 xff0c 或直接进入快速入门 一 快速入门 本指南通过一个
  • 校验和算法

    原文链接 xff1a http blog chinaunix net uid 26758209 id 3146230 html 校验和算法 经常看计算机网络相关的书时 xff0c 每次看到关于IP或者是UDP报头校验和时 xff0c 都是一
  • PID控制输出PWM核心代码(基于STM32F103)

    注 xff1a 1 如果对于PID控制原理不是很了解 xff0c 可以找些资料看 xff0c 最好先搞懂原理 2 程序中Kp Ki Kd 199 0可根据实际情况自己修改 全局变量 float target 61 30 0 目标温度 flo
  • (已修正精度 1mm左右)Realsense d435i深度相机+Aruco+棋盘格+OpenCV手眼标定全过程记录

    文章目录 2023 5更新 下面为原文 一 前期准备1 1 手眼标定原理1 2 Aruco返回位姿的原理1 3 生成一个Aruco Marker1 4 安装aruco ros包1 5 安装realsense ros包 二 实验环境三 实验过
  • 外贸常用英语词汇

    外贸常用英语词汇 国际贸易 出口信贷 export credit 出口津贴 export subsidy 商品倾销 dumping 外汇倾销 exchange dumping 优惠关税 special preferences 保税仓库 bo
  • Betaflight连接飞控相关问题

    问题描述 xff1a Betaflight连接飞控时 xff0c 若遇到 打开串口失败 xff0c 则为飞控芯片驱动未安装的原因 xff0c 此时 xff0c 在设备管理器中是看不到所连接的硬件的 解决方法 xff1a Betaflight
  • 嵌入式软件开发------指针和内存释放的问题分析

    指针和内存的问题关于指针分配是否要delete的问题 1 请大家在使用指针变量时遵守以下几点 xff0c 可以让你们在编程时 少许多的麻烦 xff0c 以下假设p为某个类型的指针变量 1 定义指针 xff1a a 定义指针变量时赋初值为ty
  • 记录下Qt各版本的下载地址,便于后期查找及下载

    记录下Qt各版本的下载地址 xff0c 便于后期查找及下载 1 所有Qt版本下载地址 xff1a http download qt io archive qt 2 所有Qt Creator下载地址 xff1a http download q
  • 计算机网络 -- RS232接口 ----OSI物理层协议----RS232接口

    个人计算机上的通讯接口之一 xff0c 由电子工业协会 Electronic Industries Association xff0c EIA 所制定的异步传输标准接口 是目前使用最广泛的串行物理接口 xff0c 必须理解 xff1a 1
  • 来自一个前端大神转产品经理后的聊天感悟

    给的学习建议 xff1a 1 推荐给我一本书 锋利的jQuery 2 学会使用思维导图工具 3 课余时间学习理财 4 研发过程中 xff0c 多多留心一些交互 xff0c 自己完善反复琢磨自己的思路 xff08 保证是最简的 xff09 5
  • 算法竞赛入门经典(第二版)-刘汝佳-第三章 数组与字符串 例题+习题(17/18)

    文章目录 说明例题例3 1 UVA 272 TeX 中的引号例3 2 UVA 10082 WERTYU例3 3 UVA 401 回文词例3 4 UVA 340 猜数字游戏的提示例3 5 UVA 1583 生成元例3 6 UVA 1584 环