自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(26)
  • 收藏
  • 关注

转载 多个文件目录下Makefile的写法

1、前言  目前从事于linux下程序开发,涉及到多个文件,多个目录,这时候编译文件的任务量比较大,需要写Makefile。关于Makefile的详细内容可以参考网上流传非常广泛的《跟我一起写Makefile》http://blog.csdn.net/haoel/article/details/2886/,作者是个大牛,非常佩服。2、简单测试  测试程序在同一个文件中,共有func.h...

2019-12-24 09:43:27 275

转载 GCC编译过程与动态链接库和静态链接库

1. 库的介绍库是写好的现有的,成熟的,可以复用的代码。现实中每个程序都要依赖很多基础的底层库,不可能每个人的代码都从零开始,因此库的存在意义非同寻常。本质上来说库是一种可执行代码的二进制形式,可以被操作系统载入内存执行。库有两种:静态库(.a、.lib)和动态库(.so、.dll)。 windows上对应的是.lib .dll linux上对应的是.a .so在这里先介绍下Linu...

2019-12-24 09:36:51 287

转载 用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 2322

转载 Makefile 使用总结

1. Makefile 简介Makefile 是和 make 命令一起配合使用的.很多大型项目的编译都是通过 Makefile 来组织的, 如果没有 Makefile, 那很多项目中各种库和代码之间的依赖关系不知会多复杂.Makefile的组织流程的能力如此之强, 不仅可以用来编译项目, 还可以用来组织我们平时的一些日常操作. 这个需要大家发挥自己的想象力. 

2016-11-11 10:12:01 480

原创 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 908

原创 C++ Primer(第五版)练习6.36 6.37

声明一个返回数组指针的函数,大致分为四种方法:普通声明、使用尾置返回类型声明、使用decltype声明、使用类型别名声明。问题:编写一个函数声明,使其返回数组的引用并且该数组包含10个string对象。一、普通声明:string (*fun(string i))[10];二、使用尾置返回类型声明:尾置返回类型是在C++11新标准中的方法,任何函数的定义都

2016-10-22 19:49:38 1132 1

转载 数组指针与指针数组的知识点总结

在看到C++ Primer返回数组指针章节中,其中有关于数组指针和指针数组的表达。一知半解,遂查了些资料,虽然只是两个词组交换了位置,但是所表达的对象却完全不相同。指针数组:array of pointers,即用于存储指针的数组,也就是数组元素都是指针数组指针:a pointer to an array,即指向数组的指针int *arr1[10]    指针数组

2016-10-22 11:47:54 604

原创 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 443

原创 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 444

原创 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 1197

原创 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 382

原创 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 319

原创 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 473

原创 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 270

原创 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 430

原创 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 444

原创 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 421

原创 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 361

原创 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 300

原创 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 468

原创 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 317

原创 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 425 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 528

原创 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 563

原创 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 599

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除