![](https://img-blog.csdnimg.cn/20201014180756738.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
c++
copbint
种一棵树,最好的时间是十年前,其次是现在!!<br>
有问题交流与讨论可以直接加我微信"copbint",CSDN回复非常不及时。
很多东西记了只是方便自己复习的,如果觉得没啥帮助请轻喷。
展开
-
Strassen矩阵乘法算法-c++实现
基本完全参考以下文章实现,不过是看了一遍之后自己为了加深理解手写的。http://www.mamicode.com/info-detail-673908.html#include "stdafx.h"#include #include #include #include using namespace std;template class Strassen{publi原创 2016-09-28 23:15:21 · 3568 阅读 · 0 评论 -
c语言中的字符串拼接
在看内核源码时,看到这样一段代码:int __init ip_vs_protocol_init(void){ char protocols[64];#define REGISTER_PROTOCOL(p) \ do { \ register_ip_vs_protocol(p); \ strcat(protocols, ", "); \ strcat(protoco...原创 2019-04-27 23:51:05 · 5020 阅读 · 0 评论 -
c中关于结构体,指针,指针的指针的理解
如果要确定一个对象,需要知道2个要素:1 对象在内存中的起始位置。2 对象的结构。从而知道从起始位置之后的多少个字节都属于此对象。从而也就可以获取到结构中每个元素的值。一个指针就包含这两个要素:指针的值表示对象在内存中的起始位置。指针的类型,则说明了指针所指向的内存的大小及结构。在c中,直接声明的方式声明的对象:struct Tool tool;tool本身就包含了完整的信息。对象的地...原创 2019-05-01 17:28:42 · 719 阅读 · 0 评论 -
c函数指针
虽然是一个java程序员。但是c的东西不能丢啊,很多底层的东西都是c的。好记性不好烂笔头,基础知识需要一点一点的积累。都知道c中区别与其他语言的就是指针,初学者常常被指针搞得痛不欲生。变量的指针即是变量在内存中的地址。同样,函数的指针指的也就是函数在内存中的地址。经常见到的是在结构体中使用函数指针:#include <stdio.h>#include <string....原创 2019-04-21 23:07:22 · 131 阅读 · 0 评论 -
linux下getopt, getopt_long函数的使用
在linux下使用的各种命令行工具一般都支持传递参数,来决定工具的行为。解析参数,是各种程序最为基本的一个功能。所以,glibc提供了函数库getopt和getopt_long来帮助简化程序的开发工作。get_optget_opt函数的声明在头文件unistd.h中。unistd是Unix Standard的缩写,unistd.h是POSIX 操作系统 API 的访问功能的集合。gcc...原创 2019-04-09 23:45:33 · 500 阅读 · 0 评论 -
C++中Main函数参数argc,argv用法
int main(int argc, char** argv)argc为传入参数个数,argv是具体的参数。我知道的两种使用方法:1.在命令行中使用,如传入"test.exe f:\a.txt f:\b.txt",那么:argc=3;argv[0] = test.exe (调用可执行文件的时候其实.exe后缀可以省略掉,但是要注意如果是打开文件后缀名不可省略)argv[1] = f:\a.txt原创 2017-03-02 16:34:39 · 1719 阅读 · 1 评论 -
算法导论第八章思考题-c++
8-2.e 线性时间的原址排序#include "stdafx.h"#include #include #include #include #include using namespace std;void sort_WithLinerCost_InOriginPlace(int a[],int n,int k)//所有的元素都属于1到k{ int *c = new int[原创 2016-10-08 04:04:25 · 635 阅读 · 0 评论 -
算法导论第八章计数排序-基数排序-桶排序-c++
1.计数排序#include "stdafx.h"#include #include #include #include #include using namespace std;int* countSort(int a[],int n,int k)//n means the length of a,k means the max of a[i]+1{ int *b = ne原创 2016-10-07 12:41:37 · 336 阅读 · 0 评论 -
算法导论第七章-快速排序-c++
#include "stdafx.h"#include #include #include #include #include using namespace std;int PARTITION(int a[],int p,int r){ int x = a[r]; int i = p - 1; for(int j=p;j<=r-1;j++) { if(a[j] <原创 2016-10-03 23:26:43 · 280 阅读 · 0 评论 -
算法导论第五章
题目:Describe an implementation of the procedure RANDOM(a, b) that only makes calls to RANDOM(0, 1). What is the expected running time of your procedure, as a function of a and b?#include "stdio.h原创 2016-09-30 14:04:20 · 404 阅读 · 0 评论 -
当一个变量占多个字节的内存时,变量的指针指向的是高地址还是低地址?
一直有一个疑惑:int a =0x01020304;如果a在内存中按如下方式存储(小端机器):100-103表示地址。int *address=&a;那么address 到底是等于100还是103呢?验证代码:test.cvoid main(){ int a=0x01020304; unsigned char* a1=(unsigned char*)(&a...原创 2019-09-08 15:20:27 · 2764 阅读 · 4 评论