- 博客(26)
- 收藏
- 关注
转载 多个文件目录下Makefile的写法
1、前言 目前从事于linux下程序开发,涉及到多个文件,多个目录,这时候编译文件的任务量比较大,需要写Makefile。关于Makefile的详细内容可以参考网上流传非常广泛的《跟我一起写Makefile》http://blog.csdn.net/haoel/article/details/2886/,作者是个大牛,非常佩服。2、简单测试 测试程序在同一个文件中,共有func.h...
2019-12-24 09:43:27 278
转载 GCC编译过程与动态链接库和静态链接库
1. 库的介绍库是写好的现有的,成熟的,可以复用的代码。现实中每个程序都要依赖很多基础的底层库,不可能每个人的代码都从零开始,因此库的存在意义非同寻常。本质上来说库是一种可执行代码的二进制形式,可以被操作系统载入内存执行。库有两种:静态库(.a、.lib)和动态库(.so、.dll)。 windows上对应的是.lib .dll linux上对应的是.a .so在这里先介绍下Linu...
2019-12-24 09:36:51 292
转载 用PWM实现多个呼吸灯间歇发光
#!/usr/bin/env python2.7 import RPi.GPIO as GPIO # always needed with RPi.GPIOfrom time import sleep # pull in the sleep function from time module GPIO.setmode(GPIO.BOARD) # choose BCM or BOARD
2016-12-07 18:48:11 2331
转载 Makefile 使用总结
1. Makefile 简介Makefile 是和 make 命令一起配合使用的.很多大型项目的编译都是通过 Makefile 来组织的, 如果没有 Makefile, 那很多项目中各种库和代码之间的依赖关系不知会多复杂.Makefile的组织流程的能力如此之强, 不仅可以用来编译项目, 还可以用来组织我们平时的一些日常操作. 这个需要大家发挥自己的想象力.
2016-11-11 10:12:01 483
原创 C++ Primer(第五版)练习7.23 7.27 7.32
#include#include#includeusing namespace std;class Screen;class Window_mgr{private: vector screens;public: using Screen_index = vector::size_type; void clear(Screen_index i); Window_mgr(
2016-10-31 11:16:04 914
原创 C++ Primer(第五版)练习6.36 6.37
声明一个返回数组指针的函数,大致分为四种方法:普通声明、使用尾置返回类型声明、使用decltype声明、使用类型别名声明。问题:编写一个函数声明,使其返回数组的引用并且该数组包含10个string对象。一、普通声明:string (*fun(string i))[10];二、使用尾置返回类型声明:尾置返回类型是在C++11新标准中的方法,任何函数的定义都
2016-10-22 19:49:38 1136 1
转载 数组指针与指针数组的知识点总结
在看到C++ Primer返回数组指针章节中,其中有关于数组指针和指针数组的表达。一知半解,遂查了些资料,虽然只是两个词组交换了位置,但是所表达的对象却完全不相同。指针数组:array of pointers,即用于存储指针的数组,也就是数组元素都是指针数组指针:a pointer to an array,即指向数组的指针int *arr1[10] 指针数组
2016-10-22 11:47:54 608
原创 C++ Primer(第五版)练习6.33
#include #include #include using namespace std;void print_vector(vector::iterator ptr, vector &a) // 1{ if (ptr != a.begin()) print_vector(ptr - 1, a); //2 cout << *ptr << endl;}int main
2016-10-21 21:49:03 447
原创 C++ Primer(第五版)练习6.27
#include #include #include using namespace std;int sum(initializer_list n){ int s = 0; for (auto beg = n.begin(); beg != n.end(); ++beg) s += *beg; return s;}int main(){ int s; int a
2016-10-21 16:47:02 446
原创 C++ Primer(第五版)练习6.26
#include using namespace std;int main(int argc, char **argv){ for (int i = 0; i < argc; i++) cout << "Argument " << i << " is " << argv[i] << endl; system("pause"); return 0;}该程序编译运行成功,产生
2016-10-21 15:45:02 512
转载 main:处理命令行选项 知识点总结
main()称之为主函数,是所有程序运行的入口,可以分为有参或无参两种情况。一般情况下我们定义的main函数都是空形参列表:int main() {......}但有时候我们确实需要给main函数传递实参,一种常见的情况是用户通过设置一组选项来确定函数所要执行的操作,这些命令行选项通过两个(有些实现允许更多的参数,但这只是对标准的扩展)形参传递给main函数:int mai
2016-10-21 15:05:42 1200
原创 C++ Primer(第五版)练习6.22
#include #include #include using namespace std;void change(int *p1, int *p2){ int c; c = *p1; *p1 = *p2; *p2 = c;}int main() { int a1, a2; int *ptr1,*ptr2; cin >> a1 >> a2; ptr1 = &
2016-10-21 14:10:15 385
原创 C++ Primer(第五版)练习6.21
#include #include #include using namespace std;int max(int a, int *p){ if (a > *p) return a; else return *p;}int main() { int a1, a2, m; int *ptr; cin >> a1 >> a2; ptr = &a2; m =
2016-10-21 14:02:47 322
原创 C++ Primer(第五版)练习6.17
#include #include #include using namespace std;int judge(const string &a) //判断是否有大写{ for (auto &b : a) { if (b >= 65 && b <= 90) { return 1; break; } else return 0; }}vo
2016-10-19 21:28:00 476
原创 C++ Primer(第五版)练习6.5
#include #include #include using namespace std;int abs(int val){ if (val > 0) val = val; else val = -val; return val;}int main() { int num, val; cin >> num; val = abs(num); cout
2016-10-19 15:11:02 271
原创 C++ Primer(第五版)练习5.5
#include #include #include using namespace std;int main() { const vector scores = { "F","D","C","B","A","A++" }; string lettergrade; int grade; cin >> grade; if (grade < 60) lettergrade
2016-10-17 21:27:25 434
原创 C++ Primer(第五版)练习4.22
版本一:利用条件运算符#include #include #include using namespace std;int main() { int grade; string finalgrade; cin >> grade; finalgrade = (grade > 90) ? "high pass" : (grade > 75) ? "pass" : (grade
2016-10-17 19:46:57 446
原创 C++ Primer(第五版)练习4.21
#include #include #include using namespace std;int main() { vector a{1,2,3,4,5,6,7,8,9}; for (auto &i : a) { if (i % 2) { cout << i << " "; i *= 2; } } cout << endl; for (auto
2016-10-17 19:36:28 424
原创 C++ Primer(第五版)练习3.35
#include #include #include using namespace std;int main() { int a[5] = { 1,1,1,1,1 }; int *p = a; for (int i = 0; i != end(a) - begin(a); ++i) *(p + i) = 0; for (auto i : a) //利用范围for输出数
2016-10-09 21:00:21 363
原创 C++ Primer(第五版)练习3.32
#include #include #include using namespace std;int main() { int a[10] = {}; int copy[10] = {}; for (int i = 0; i < 10; i++) a[i] = i; for (int i = 0; i < 10; i++) copy[i] = a[i]; for (
2016-10-07 20:17:53 305
原创 C++ Primer(第五版)练习3.31
很简单的一个小代码,用了for循环和范围for#include #include #include using namespace std;int main() { int a[10] = {}; for (int i = 0; i < 10; i++) a[i] = i; for (auto c : a) cout << c << " "; cout << en
2016-10-07 20:14:40 469
原创 C++ Primer(第五版)练习3.25
首先,先给出书中所示的利用下标运算符实现划分分数段的程序:#include #include #include using namespace std;int main(){ vector scores(11, 0); unsigned grade; while (cin >> grade) if (grade <= 100) ++scores[grade /
2016-10-07 18:48:27 321
原创 C++ Primer(第五版)练习3.20
第1小问:经过在网上的搜索,我不太同意这位前辈所说的观点,(点击打开链接),个人认为在本小问中不需要讨论奇偶性。代码如下:#include #include #include using namespace std;int main(){ vector num; int a, sum; while (cin >> a) num.push_back(a); for (vec
2016-10-07 16:31:05 432 2
原创 C++ Primer(第五版)练习3.22
这题我遇到的一些不懂的地方:先贴上能Debug的代码如下,这是参考网络上的写的————————————————————————————————————————#include #include #include using namespace std;int main(){ string text = ("Hello,my name is YJ1an.Nice to
2016-10-07 15:56:13 535
原创 C++ Primer(第五版)练习3.6
#include #include using namespace std;int main(){ string a("some string"); for (auto &c : a) if (!isspace(c)) c = 'X'; cout << a << endl; system("pause"); return 0;}
2016-10-07 15:02:35 565
原创 C++ Primer(第五版)练习3.23
#include #include #include using namespace std;int main(){ vector number; int a; while (cin >> a) number.push_back(a); for (auto &c : number) c *= 2; for (auto c : number) cout << c <<
2016-10-07 14:55:11 600
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人