- 博客(19)
- 收藏
- 关注
原创 ubuntu18.04+ROS melodic报错整理
标题ubuntu18.04+ROS melodic报错整理CMake Error at /usr/lib/x86_64-linux-gnu/cmake/Qt5Core/Qt5CoreMacros.cmake:336 (message):Can not use “Positioning” module which has not yet been found.Call Stack (most recent call first):camp/CMakeLists.txt:129 (qt5_use
2021-08-12 10:29:48
1302
原创 王道机试5.4 最短路径
王道机试5.4 最短路径例5.6 最短路径问题#include<stdio.h>#include<vector>using namespace std;bool mark[1001];int dis[1001];int cost[1001];struct Edge{ int d; int p; int next;};vector <Edge> edge[100000];int main(){ int n,m,s,t; while
2020-07-01 23:52:57
128
原创 王道机试5.3 最小生成树 含练习
王道机试5.3 最小生成树 含练习例5.3 还是畅通工程#include<stdio.h>#include<algorithm>using namespace std;#define N 101int tree[N];struct edge{ int a,b; int cost; bool operator < (const edge &A) const { return cost<A.cost; } }edge[6000];
2020-07-01 20:46:13
116
转载 王道机试5.2 并查集 含练习
王道机试5.2 并查集 含练习例5.1 畅通工程#include<stdio.h>using namespace std;int tree[1000]; int findroot(int x){ if(tree[x]==-1) return x; else { int ret=findroot(tree[x]); tree[x]=ret; return ret; } } int
2020-06-23 17:32:12
166
原创 王道机试4.9 高精度整数 含练习
王道机试4.9 高精度整数 含练习例4.11 a+b#include<stdio.h>#include<string.h>struct biginteger{ int digit[1000]; int size; void init() { for(int i=0;i<1000;i++) digit[i]=0; size=0; } void output() { for(int i=size-1;i>=0;i--)
2020-06-20 20:40:09
192
原创 王道机试4.7 分解素因数 含练习
王道机试4.7 分解素因数 含练习例4.8质因数的个数#include<stdio.h>int prime[100000];int primesize;bool mark[100001];void init(){ for(int i=1;i<=100000;i++) mark[i]=false; primesize=0; for(int i=2;i<=100000;i++) { if(mark[i]==true) continue; pr
2020-06-18 02:44:30
103
原创 王道机试4.6 素数筛法 含练习1
王道机试4.6 素数筛法 含练习例4.6素数判定#include<stdio.h>#include<math.h>bool isprime(int x){ if(x<=1) return false; int bound=(int)sqrt(x)+1; for(int i=2;i<bound;i++) { if(x%i==0) return false; } return true;}int main(){ int n; whil
2020-06-07 23:30:35
102
原创 王道机试 4.4最大公约数
王道机试 4.4最大公约数例4.4最大公约数#include<stdio.h>int gcd(int a,int b){ if(b==0) return a; else return gcd(b,a%b);}int main(){ int x,y; while(scanf("%d%d",&x,&y)!=EOF) { printf("%d\n",gcd(x,y)); } return 0;}...
2020-06-07 22:47:15
105
原创 王道机试 4.2 数位拆解 含练习
王道机试 4.2 数位拆解 含练习例4.1数位拆解#include<stdio.h> int main(){ int x,y; while(scanf("%d%d",&x,&y)!=EOF) { int buf1[11],buf2[11],size1=0,size2=0; while(x!=0) { buf1[size1++]=x%10; x=x/10
2020-06-07 20:46:02
119
原创 机试指南 4.1%运算符 练习题
练1:还是A+B#include<stdio.h>int tail(int x,int n){ int tmp=1; for(int i=0;i<n;i++) { tmp=tmp*10; } return x%tmp;}int main(){ int x,y,n; while(scanf("%d%d%d",&x,&y,&n)!=EOF) { if(x==0&&y==0) break; if(tail(x,
2020-06-07 19:54:52
205
原创 机试指南 3.4二叉排序树
机试指南 3.4二叉排序树例3.5二叉排序树#include<stdio.h>struct node{ node *lchild; node *rchild; int c;}tree[110];int loc;node *create(){ tree[loc].lchild=NULL; tree[loc].rchild=NULL; return &tree[loc++];}void preOrder(node *t){ printf("%d ",t
2020-06-07 18:01:57
77
原创 机试指南 3.3二叉树 含练习题
机试指南 3.3二叉树例3.4二叉树遍历#include<stdio.h>#include<string.h>struct node{ node *lchild; node *rchild; char c;}tree[50];int loc;char str1[30];char str2[30];node *create();void postOrder(node *t);node *build(int s1,int e1,int s2,int e
2020-06-07 15:38:39
92
原创 机试指南 3.1栈的应用 含练习
机试指南 3.1栈的应用例3.2 简单计算器#include<stack>#include<stdio.h>using namespace std;int mat[][5]={1,0,0,0,0, 1,0,0,0,0, 1,0,0,0,0, 1,1,1,0,0, 1,1,1,0,0, }; char str[200];stack<char> op;stack<double> in;void getOp(boo
2020-06-07 00:39:28
188
1
原创 机试指南 3.2哈夫曼树 含练习
机试指南 3.2哈夫曼树例3.3 哈夫曼树#include<stdio.h>#include<queue>using namespace std;priority_queue< int,vector<int>,greater<int> > Q;int main(){ int n; while(scanf("%d",&n)!=EOF) { if(Q.empty()==false) Q.pop(); for(in
2020-05-21 14:49:53
98
原创 机试指南 2.4排版
机试指南 2.4排版例2.8 叠筐#include<stdio.h>char hash[80][80]; int main(){ int n; char a,b; int first=1; while(scanf("%d %c %c",&n,&a,&b)!=EOF) { if(first==1) first=0; else printf("\n"); int base=n/2+1; for(int i=1;i<=
2020-05-19 23:58:25
63
原创 机试指南 2.3Hash的应用
机试指南 2.3Hash的应用例2.5 统计同成绩学生人数#include<stdio.h>int main(){ int n; while(scanf("%d",&n)!=EOF) { int hash[101]={0}; for(int i=0;i<n;i++) { int x; scanf("%d",&x); hash[x]++; } int y; scanf("%d",&y); printf(
2020-05-19 17:31:20
123
原创 机试指南 2.2日期
机试指南 2.2日期例2.3 日期差值#include<stdio.h>#define ISYEAR(x) ((x%100!=0)&&(x%4==0)) || (x%400==0) int dayOfMonth[13][2]={0,0, 31,31, 28,29, 31,31, 30,30, 31,31, 30,30, 31,31, 31,31, 30,30, 31,31, 30,30, 31,31};struct Date{ int year; int mont
2020-05-19 14:01:13
126
原创 机试指南 2.1排序
机试指南 2.1排序例2.1 排序#include<stdio.h>#include<algorithm>using namespace std;int main(){ int n; int buf[100]; while(scanf("%d",&n)!=EOF) { for(int i=0;i<n;i++) scanf("%d",&buf[i]); sort(buf,buf+n); for(int j=0;j<n
2020-05-19 11:42:17
92
原创 机试指南 2.5查找
机试指南 2.5查找例2.9 找x#include<stdio.h>int main(){ int n; int x; int buf[200]; int ans; while(scanf("%d",&n)!=EOF) { ans=-1; for(int i=0;i<n;i++) scanf("%d",&buf[i]); s...
2020-05-02 13:02:11
136
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人