c++ 代码
楚江课的救赎
这个作者很懒,什么都没留下…
展开
-
cblas_sgemm 矩阵乘法
virtual vector<Feature> get_nbest(Feature & feature_obj, int n_top=10){ //debug_marix_get_max_use();; //debug_marix_head(10); MutexLockGuard lock(mutex_); // AutoWrite au...原创 2019-03-13 16:41:15 · 955 阅读 · 0 评论 -
简单链表堆栈
#include#includetypedef int datatype;typedef struct node{datatype data;struct node *next;}linkstack;linkstack *top;void initiate(linkstack *top)//链栈的初始化{top=NULL;return ;}原创 2013-08-08 18:00:31 · 1441 阅读 · 0 评论 -
write,read用法,笔记。
#include#include#include#include#include#includeusing namespace std;class News{public: News () {number=0;name=string("unkonw");score1=0;score2=0;} News(int value1,string原创 2013-06-18 23:43:45 · 937 阅读 · 0 评论 -
对16进制数处理
分析一下从第一个到最后一个有什么递进或者什么规律 可以推出之后的00000017000A0B010F7363656E654964040107636D64048396310100000017000A0B010F7363656E654964040207636D64048396310100000017000A0B010F7363656E654964040307636D64048396310100000原创 2013-06-17 23:14:56 · 1053 阅读 · 0 评论 -
linux统计有文件个数。
#include#include#include#include#includeusing namespace std;int main(int argc, char* argv[]){ for (int i = 0; i cout cout cout string filename; ci原创 2013-06-09 23:41:29 · 1138 阅读 · 0 评论 -
将"3-4.5/6*7"之类的式子字符提取出数字
3-4.5/6*7#include#include#include#include#include#includeusing namespace std;int main(){string input;coutcin>>input;string temp;原创 2013-06-10 00:29:22 · 1246 阅读 · 0 评论 -
简单的调用shell命令的方法。
#include#includeusing namespace std;int main(int argc, char* argv[]){ for (int i = 0; i cout cout char cmd[81]; while(cin.getline(cmd, 80)){ system(cmd);原创 2013-06-09 23:18:08 · 919 阅读 · 0 评论 -
用C++写一个布尔函数 该函数获取一个以0或1为原始的数值A[n](n≥1),并要求确定每个连续为1的序列的大小是否为偶数
该函数获取一个以0或1为原始的数值A[n](n≥1),并要求确定每个连续为1的序列的大小是否为偶数#include using namespace std;bool fun(int *a,int n){int i=0;int coun=0;while(i!=n){if(a[i]==1){coun++;i++;}else{i++;if(coun%2!=0)return false;coun原创 2013-05-10 12:28:42 · 2726 阅读 · 0 评论 -
针对一个文件 统计其中的单词和字符数 找出文件中出现次数最多的单词数 将文件中出现的单词按频率进行排序并输出
#include #include #include #include #include #include #include#includeusing namespace std;int cmp(const pair & x, const pair& y){ return x.second > y.second;}int main(原创 2013-05-09 13:16:39 · 2126 阅读 · 0 评论 -
n对夫妻站一排,夫妻不能挨着的c++程序
#include #include #include #include using namespace std;bool xiangling(int *a,int n){for(int i=0;iif(a[i]==a[i+1]){return true;}return false;}void swap1(int *a,int *b)原创 2013-05-08 00:09:46 · 1502 阅读 · 0 评论 -
string初始化的一点记录
#include #include #include using namespace std;int main(){ cout cout char temp[100]; cin.getline(temp,100); string str(temp); char ch='a'; str=str原创 2013-05-06 12:36:40 · 788 阅读 · 0 评论 -
virtual 虚函数
#include using namespace std;class a{public:virtual void f(){cout}};class b:public a{public: void f() ////// 没有virtual也照,virtua原创 2013-05-04 00:07:29 · 840 阅读 · 0 评论 -
linux emacs 黑客配置 搞成功了记录 下好用 要摆脱键盘 emacs就是evil
大神的配置文件在github上https://github.com/purcell/emacs.d1,把隐藏文件夹里面的.emacs删除l。2.把下载下来的文件放在.emacs.d里面3.重启emacs要下的见我资源解压后放在.emacs.d中。原创 2013-03-10 21:44:04 · 1948 阅读 · 0 评论 -
string 转化为int,int转化为string
将string转化为int#include #include#includeusing namespace std;int main(){ string str="110"; istringstream istr(str); int i=0; istr>>i; cout cout return原创 2013-05-16 12:37:30 · 1359 阅读 · 0 评论 -
c++函数返回值与引用
原文http://blog.csdn.net/piratejk/article/details/6162554对于函数的返回值,看似简单,但并非如此,比如:int func(int a);该函数会返回一个int型,如果进行一个调用int result=func(3);会发生什么情况?首先,func将返回值复制到一个匿名临时变量中,在这里假设该临时变量为anony(其实是没有转载 2013-04-14 12:11:34 · 897 阅读 · 0 评论 -
sstringstream
#include#include#include#includeusing namespace std;int main(){ string s="2013/4/8"; int y ,m , d; char c; stringstream ss(s); ss>>y>>c>>m>>c>>d; cout<<y<<" "<<m<<" "<<原创 2013-04-12 17:34:45 · 992 阅读 · 0 评论 -
数组与指针
数组与指针原创 2013-08-26 20:36:59 · 677 阅读 · 0 评论 -
二叉树 插入
代码如下,姑且从一个叫做tree.in的文件中读取数据,在cout中输出,每个输出占单独一行。函数功能基本就不用说明了吧(要说明可以在追问中提出来)#include#includetypedef unsigned int uint;using namespace std;ifstream fin("tree.in");class BST{private: struct Node {原创 2013-09-14 17:53:03 · 1973 阅读 · 0 评论 -
有关 vitural的派生类的派生类
#include #include #include using namespace std;class B {public:virtual void fun() {printf("base");} };class C :public B{public:virtual void fun(int a) {printf("derive原创 2013-10-02 23:09:56 · 738 阅读 · 0 评论 -
undefined reference to
多个库文件链接顺序问题这种问题非常隐蔽,不仔细研究,可能会感到非常地莫名其妙。以第三个示例为测试代码,把链接库的顺序换一下,如下所示: $ gcc -o main main.c func.a test.a test.a(test.o): In function `test': test.c:(.text+0x13): undefined reference...原创 2019-03-15 19:43:39 · 1636 阅读 · 0 评论 -
.SUFFIXES : .cpp .$(OBJEXT) .exe
.SUFFIXES 后缀自定义规则# From "Thinking in C++, 2nd Edition, Volume 1, # Annotated Solutions Guide" by Chuck Allison# At http://www.BruceEckel.com# (c)2001 MindView Inc. Copyright notice in Copyright.txt...原创 2018-03-02 17:06:30 · 1645 阅读 · 0 评论 -
适配器模式
我理解的适配器模式就是两套接口, 一套复用, 通过一个适配类调用新的类。适配器模式适配器模式(Adapter Pattern)是作为两个不兼容的接口之间的桥梁。这种类型的设计模式属于结构型模式,它结合了两个独立接口的功能。这种模式涉及到一个单一的类,该类负责加入独立的或不兼容的接口功能。举个真实的例子,读卡器是作为内存卡和笔记本之间的适配器。您将内存卡插入读卡器,再将读卡器插入笔记转载 2018-02-05 15:53:35 · 280 阅读 · 0 评论 -
创建模式-抽象工厂模式
抽象工厂模式抽象工厂模式(Abstract Factory Pattern)是围绕一个超级工厂创建其他工厂。该超级工厂又称为其他工厂的工厂。这种类型的设计模式属于创建型模式,它提供了一种创建对象的最佳方式。在抽象工厂模式中,接口是负责创建一个相关对象的工厂,不需要显式指定它们的类。每个生成的工厂都能按照工厂模式提供对象。介绍意图:提供一个创建一系列相关或相互依赖对象的接口,而无需指原创 2018-01-25 21:57:03 · 382 阅读 · 0 评论 -
写了 windows RC 资源多语言string 替换的程序,发出来看下。
#include #include #include #include #include #include // std::ifstream#include #include // std::cout#include // std::ifstreamusing namespace std;vector readfile1( char *原创 2015-04-21 19:07:45 · 834 阅读 · 0 评论 -
C++成员函数的重载、覆盖与隐藏 .
原文链接http://blog.csdn.net/sendy888/article/details/1739113 成员函数的重载、覆盖(override)与隐藏很容易混淆,C++程序员必须要搞清楚概念,否则错误将防不胜防。成员函数被重载的特征:(1)相同的范围(在同一个类中);(2)函数名字相同;(3)参数不同;(4)virtual 关键字可有可无。覆盖:派生类函数覆转载 2014-09-24 16:53:48 · 700 阅读 · 0 评论 -
编译器总是要为函数的每个参数制作临时副本
1. 关于内存的问题: void GetMemory(char *p, int num) { p = (char*)malloc(sizeof(char)*num); } void Test(void) { char *str = NULL;转载 2014-08-14 08:42:27 · 1372 阅读 · 0 评论 -
c++ 二进制 八进制 十进制 十六进制 输出
#include#includeusing namespace std;int main(){ int i; cout cin>>i; cout(i) cout return 0;} 二进制 如上八进制 oct十进制 dec十六进制 hex原创 2014-09-04 17:54:30 · 1155 阅读 · 0 评论 -
stl中的remove返回的是什么
我将从remove的复习开始这个条款,因为remove是STL中最糊涂的算法。误解remove很容易,驱散所有关于remove行为的疑虑——为什么它这么做,它是怎么做的——是很重要的。这是remove的声明:templateForwardIterator remove(ForwardIterator first, ForwardIterator last, const T&转载 2014-06-06 11:44:43 · 738 阅读 · 0 评论 -
C++本质:类的赋值运算符=的重载,以及深拷贝和浅拷贝
C++本质:类的赋值运算符=的重载,以及深拷贝和浅拷贝很好的文章学习,转载的。 C++本质:类的赋值运算符=的重载,以及深拷贝和浅拷贝C++本质:类的赋值运算符=的重载,以及深拷贝和浅拷贝关键词:构造函数,浅拷贝,深拷贝,堆栈(stack),堆heap,赋值运算符摘要: 在面向对象程序设计中,对象间的相互拷贝和赋值是经常进行的操作。 如果对象在申明的原创 2014-01-07 11:06:40 · 858 阅读 · 0 评论 -
链表的插入操作
链表的插入操作#include#include#includeusing namespace std;struct Computer { int CNumber; string CName; double CPrice; Computer() //默认的构造函数 { CNumber=0;原创 2014-01-06 09:21:52 · 1470 阅读 · 0 评论 -
笔试地小题,阴沟里翻船。
#include#includeusing namespace std;int fun(){ int m=2; return (m++);}int main(){ cout<<fun(); int n; while(n<100) { cout<<n; n原创 2013-12-07 11:35:58 · 783 阅读 · 0 评论 -
c++ 字符分割实现
原文链接:http://www.cnblogs.com/MikeZhang/archive/2012/03/24/MySplitFunCPP.html还不错,学习下。 1 /* 2 File : split1.cpp 3 Author : Mike 4 E-Mail : Mike_Zhang@live.com 5 */转载 2013-10-30 13:15:11 · 748 阅读 · 0 评论 -
centos 上搭建c++开发环境
1. 安装g++ yum install gcc-c++2 安装codeblocks yum install codeblocks3 安装xtermyum install xterm原创 2013-10-29 23:17:38 · 1527 阅读 · 0 评论 -
java 和c++关于默认构造函数的区别
java 默认的构造函数 Node node=new Node();c++ 默认的构造函数 Node *node=new Node; //iwithout ();原创 2013-10-08 00:05:48 · 980 阅读 · 0 评论 -
map<string,int>
#include #include #include #include #include using namespace std;void main(){ typedef map::iterator mit; map ma; mit it; ifstream in("in.txt"); int c=0; string str; string st; while(原创 2013-04-10 18:42:59 · 3701 阅读 · 0 评论 -
string时间处理的很好
#include#include#include#include#include#include#includeusing namespace std;int main(){ string time="2013/4/8"; string year(time.begin(),time.begin()+4); string month(tim原创 2013-04-08 13:07:39 · 779 阅读 · 0 评论 -
第一个数据库程序纪念下
#include#include#include#include#include#include"mysql/mysql.h"using namespace std;int main(){ MYSQL my_connection; MYSQL_RES * res_ptr; MYSQL_ROW sqlrow; mysql_in原创 2013-03-23 17:26:48 · 793 阅读 · 0 评论 -
简单学生管理系统
学生管理系统内容:针对若干学生信息(至少包括学生学号、年龄、性别等信息),设计一个学生信息管理系统。要求该组数据在程序运行时已经被赋过初值(在程序里写好初始值,而不是键盘输入初始值)。功能:用户界面设计与实现:提供相关操作步骤的指导性提示,可以参考图2的形式。在指定位置插入1名学生信息:从键盘输入要插入学生信息以及插入位置(按存储原创 2013-02-18 17:54:55 · 1334 阅读 · 0 评论 -
c++仿函数
Apply function to rangeApplies function fn to each of the elements in the range [first,last).The behavior of this template function is equivalent to:123456789templatec原创 2013-02-18 14:30:53 · 586 阅读 · 0 评论 -
emacs 安装插件造轮子
项目地址:http://www.emacswiki.org/emacs/AutoComplete#toc2 ( ubuntu下firefox,在大巴里插个链接都得等半天。。。) 下载地址:http://cx4a.org/software/auto-complete/#Latest_Stable ubuntu下安装方法: 1、解压缩auto-compl转载 2013-02-16 20:08:50 · 958 阅读 · 0 评论