摘要:通过传入从START_YEAR到当前时间的秒数,计算当前日期与时间。#define START_YEAR (1985)#define SECOND_DAY (86400) //60*60*24#define SECOND_HOUR (3600) //60*60#define SECOND_MIN (60) //60const unsigned short int mon_yday[][13] ={ /* Normal years. */ { 0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 33...
阅读全文
随笔分类 - C/C++
摘要:(转)从RGB色转为灰度色算法----本文摘自作者ZYL910的博客一、基础 对于彩色转灰度,有一个很著名的心理学公式: Gray = R*0.299 + G*0.587 + B*0.114二、整数算法 而实际应用时,希望避免低速的浮点运算,所以需要整数算法。 注意到系数都是3位精度的没有,我们可以将它们缩放1000倍来实现整数运算算法: Gray = (R*299 + G*587 + B*114 + 500) / 1000 RGB一般是8位精度,现在缩放1000倍,所以上面的运算是32位整型的运算。注意后面那个除法是整数除法,所以需要加上500来实现四舍五入。 就是由于该算法...
阅读全文
摘要:转到CString型//int -> CStringCString.format(”%d”, int);//string -> CStringCString.format(”%s”, string.c_str());//char -> CString//方法1.CString.format(”%s”, char*);//方法2.char * charpoint = ”give string a value”;CString strtest=charpoint;转到string型//char -> stringstring s(char *); //只能初始化,在不是初始
阅读全文
摘要:在使用QT + VS2005编译程序时,有时出现如下错误:错误 1 error LNK2001: 无法解析的外部符号 "public: virtual struct QMetaObject const * __thiscall Widget::metaObject(void)const " (?metaObject@Widget@@UBEPBUQMetaObject@@XZ) 错误 2 error LNK2001: 无法解析的外部符号 "public: virtual void * __thiscall Widget::qt_metacast(char const
阅读全文
摘要:The following is the most common method for checking if file exist:#include <sys/stat.h>bool FileExist(const char* FileName){ struct stat my_stat; return (stat(FileName, &my_stat) == 0);}//Example Usageint main(int argc, char* argv[]){ bool v1 = FileExist("c:\\autoexec.bat"); boo
阅读全文

浙公网安备 33010602011771号