C++/C
文章平均质量分 50
lovelyloulou
Computer Vision,machine learning,Computer Graphics
展开
-
cin.getline和cin合用的时候
getline有两种,一个是属于string的(getline(cin,s)),一个是属于istream的(cin.getline(s,maxsize,delim)) 当用cin输入了数据后,在接着使用cin.getline()时,需要先用cin.get()读掉回车符,否则回车符将被cin.getline读取 记录一下,免得再犯错。。原创 2010-03-07 18:24:00 · 931 阅读 · 0 评论 -
Qt中移动QGraphicsItem的注意问题,path的闭合
主要针对QGraphicsPathItem一般一个复杂的封闭曲线可能是由多条简单曲线拼接而成比如我的项目中,使用了分段bezier,每段bezier至多为二次。每段bezier我都保存了其3个或者2个control point于是我构造path的时候,每次都先moveTo到bezier的起点,然后quadTo或者lineTo封闭曲线是构造原创 2011-11-18 19:25:21 · 3499 阅读 · 0 评论 -
C++获取当前日期时间的方法
//方案— 优点:仅使用C标准库;缺点:只能精确到秒级#include #include int main( void ) { time_t t = time(0); char tmp[64]; strftime( tmp, sizeof(tmp), "%Y/%m/%d %X %A 本年第%j天 %z",localtime(&t) );转载 2012-01-08 22:01:16 · 7344 阅读 · 0 评论 -
error2248 operator = 的错误
转载自:http://blog.csdn.net/vincent_lon/article/details/29502181>e:/program files/microsoft visual studio 9.0/vc/atlmfc/include/afxtempl.h(776) : error C2248: 'CObject::operator =' : cannot acc转载 2012-02-15 09:50:37 · 1611 阅读 · 0 评论 -
error LNK2005: _malloc already defined in LIBCMT.lib(malloc.obj)
转自:http://blog.csdn.net/magictong/article/details/61051601>Linking...1>msvcrt.lib(ti_inst.obj) : error LNK2005: "private: __thiscall type_info::type_info(class type_info const &)" (??0ty转载 2012-02-24 16:32:15 · 2986 阅读 · 0 评论 -
没有找到MSVCR100.dll解决方法
转自:http://hi.baidu.com/fjdvd/blog/item/3679b201ec3d6b154afb515d.htmlMSVCR100.dll下载(游戏丢失msvcr100.dll文件解决办法)2011-06-19 23:21:54来源:作者:浏览次数:11182[导读]丢失msvcr100.dll文件是不少单机游戏尤其是绿色免安装版的游戏常见问题,这转载 2012-02-26 14:32:42 · 70390 阅读 · 1 评论 -
如何随机移动list的迭代器
使用:template void advance (InputIterator& i, Distance n);让任何容器的迭代器移动一段距离。例子: listint> mylist; for (int i=0; i<10; i++) mylist.push_back (i*10); listint>::iterator it = mylist.begin(); advanc原创 2012-03-05 16:08:16 · 1860 阅读 · 0 评论 -
error LNK2001: unresolved external symbol "public: virtual struct QMetaObject const
这个错误的出现是因为只有加入了Q_OBJECT,你才能使用QT中的signal和slot机制。 需要在类中加入Q_OBJECT宏: class myclass: public QWidget { Q_OBJECT ...... }但是我还遇到了这样的问题,在没加Q_OBJECT的时候能编译运行,但是signal机原创 2012-03-05 17:49:18 · 6264 阅读 · 1 评论 -
GSL计算矩阵的行列式值
double get_det(gsl_matrix * A) { double det=0.0; int n = A->size1; gsl_permutation *p = gsl_permutation_calloc(n); gsl_matrix *tmpA = gsl_matrix_calloc(n, n); int signum; gsl_matrix_memc原创 2012-09-21 03:21:53 · 2371 阅读 · 0 评论 -
QGraphicsItem中子Item与父Item的消息传递问题
现在要做一个需要在父item上添加控制点(子item)来调整父item形状的功能。关键是子item移动之后,要把自己的位置信息交给父item,让父item更新自己的形状。查看了很久Qt的document,需要在父ITEM中用setFiltersChildEvents(true)来设置允许拦截所有给子item的消息,然后再重载这个函数:bool sceneEventF原创 2011-11-21 20:19:54 · 4147 阅读 · 1 评论 -
tokenizer用法,提取字符串中的单词
template , class Iterator = std::string::const_iterator, class Type = std::string > class tokenizerstring s = "this/is-a,word.";tokenizertok(s);for(tokenizer::iterator beg = tok.begin(); beg != tok.end(); ++beg)couttokenizer原创 2011-04-16 20:03:00 · 2438 阅读 · 0 评论 -
取数列中前K大的数,partial_sort用法
用法如下,排出前k大的数,而k个数之后的数不排序 int n[100];partial_sort(n,n+k,n+100,cmp);原创 2010-03-11 14:04:00 · 1097 阅读 · 0 评论 -
Boost+QT+VTK+VS2005环境配置方法
配置这个东西花了我好几天时间,以下是我总结的方法1.安装boost,下载boost 1.44的安装程序,用vs系列就不用自己编译了下载地址:http://www.boostpro.com/download/boost_1_44_setup.exe安装boost的时候,记得勾选所有Variants,否则后面编译VTK的时候可能出现找不到某lib的情况。boost安装成功后,打开VS,编译个例子试试看成功没。成功了就继续。2.为VS2005配置QT,QT也有直接的安装包,但是不建议使用,还是自行编译的好,我用安原创 2011-03-28 14:43:00 · 4600 阅读 · 0 评论 -
数组越界造成的std::bad_alloc中断
<br />std::bad_alloc异常一般是在new的时候因为内存不足而引起的<br /> <br />但是数组的越界也会导致在越界代码后进行new,ifstream,ofstream等操作抛出异常<br /> <br />比如如下代码<br /> <br /> <br />int *p = new int[0]; for(int i = 0; i < 10; ++i) p[i] = 0; ofstream ofile("test.txt", ios::out); ofile原创 2011-05-31 21:38:00 · 3694 阅读 · 1 评论 -
#和##运算符
#运算符出现在宏定义中的#运算符把跟在其后的参数转换成一个字符串。有时把这种用法的#称为字符串化运算符。例如:#definePASTE(n)"adhfkj"#nmain(){printf("%s/n",PASTE(15));}宏定义中的#运算符告诉预处理程序,把源代码中任何传递给该宏的参数转换成一个字符串。所以输出应该是adhfkj15。##运算符##运算符用于把参数连接到一起。预处理程序把出现在##两侧的参数合并成一个符号。看下面的例子:#defin转载 2011-04-11 21:03:00 · 2280 阅读 · 0 评论 -
int转string
#include #include using namespace std;string foo(int){ int i=XX; string str; stringstream out; out out>>str;//str里面就是i的值XX return str;}原创 2011-04-16 17:23:00 · 605 阅读 · 0 评论 -
Boost产生随机数
mt19937 gen;uniform_intdistribut(1, 10);//产生一个1-10范围内的随机数,这里用的是均匀分布variate_generator> die(gen, distribut);int x = die();原创 2011-04-16 20:05:00 · 2812 阅读 · 0 评论 -
boost::format
<br />boost::format<br />boost::format是用于替代c里面的sprintf,优点是类型安全,不会因为类型和参数不匹配而导致程序崩溃了<br />而且还可以重复使用参数<br /> <br />#include < boost / format.hpp > <br /> void test_format()<br /> {<br /> cout << boost::format( " writing %1%, x=%2% : %3%-th try " ) %原创 2011-04-16 20:43:00 · 775 阅读 · 0 评论 -
lexical_cast
<br />lexical_cast<br />用于将字符串转换成各种数字类型原创 2011-04-16 20:44:00 · 676 阅读 · 0 评论 -
GSL计算逆矩阵
void GetInverse(gsl_matrix *A, gsl_matrix *inverse){ int n = A->size1; gsl_matrix *tmpA = gsl_matrix_alloc(n, n); gsl_matrix_memcpy(tmpA, A); gsl_permutation *p = gsl_permutation_alloc(n); int s原创 2012-09-21 03:27:16 · 4476 阅读 · 6 评论