随笔分类 - C++
1
摘要:参考:http://www.cnblogs.com/blair/p/3229580.html(参考该文章写成)double tail(double x){ return x - floor(x);}// 判断y年m月(1,2,..,12,下同)d日是Gregorian历还是Julian历//(opt=1,2,3分别表示标准日历,Gregorge历和Julian历),是则返回1,是Julian历则返回0,// 若是Gregorge历所删去的那10天则返回-1int ifGregorian(int y, int m, int d, int opt){ if (opt == 1) ...
阅读全文
摘要:原文: http://liyiwen.iteye.com/blog/705489之前 comp.graphic.algorithms 上有一个讨论,是关于怎么样使用曲线对多边形进行插值处理,使得最终产生的曲线是光滑的而且能通过所有的顶点。Gernot Hoffmann 建议说使用著名的 B-Spline 来进行插值。这里有他当时的文章。B-Spline 在这里效果很好,它看起来就像是一个固定在多边形顶点上的橡皮尺(elastic ruler)。 但我有个大胆的推测,我觉得肯定还存在更简单的方法。比如,使用三次贝塞曲线(cubic Bezier)进行近似。贝塞尔曲线有两个固定点(起点和终点),另
阅读全文
摘要:#include "math.h"#include "stdio.h" double casm_rr ;unsigned int casm_t1;unsigned int casm_t2;double casm_x1;double casm_y1;double casm_x2;double casm_y2;double casm_f;double yj_sin2(double x){ double tt ; double ss; int ff ; double s2; int cc; ff=0; if (x3.1415926535897932) ...
阅读全文
摘要:1.下载文件 (http://code.google.com/p/protobuf/ )并解压到本地文件夹。2.确认安装过GCC(可以在终端下输入gcc - -version 测试).如果电脑上没有安装过GCC的话,你在下面步骤中会看到提示"$PATH路径中没有C编译器"(原话不记得怎么写的了,就是这个意思)。通常做开 发的MAC上都装过Xcode,很多人都说装过Xcode默认都有GCC,但我发现并不是这样,可以这样再单独安装:Xcode->Preferences->Downloads下的Components下,选择安装Command Line Tools。3.
阅读全文
摘要:http://my.oschina.net/zhoulc/blog/111929http://blog.csdn.net/vrix/article/details/7683212先贴一个博文,不过没成功。。。。利用源码编译的 : http://www.tmy13.com/?p=24加openssl编译的: http://piggyq.com/pen/compile-libcurl-and-openssl-on-android-using-ndk.html——————————————————————————————————参考:终于编译成功curl,里面有上篇文章的摘要。其实就是缺少.confi
阅读全文
摘要:首先设定环境变量:真机:export IPHONEOS_DEPLOYMENT_TARGET="4.3"export CC="/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/llvm-gcc-4.2"export CFLAGS="-arch armv7 -arch armv7s -pipe -Os -gdwarf-2 -isysroot /Applications/Xcode.app/Contents/Develope
阅读全文
摘要:#include <cstdlib>#include <iostream>using namespace std;template<typename T>class Heap//最大堆{private: int currentSize; int maxSize; T *heapArray; public: Heap(int size = 10) { currentSize = 0; maxSize = size; //初始化堆容量 heapArray = new T[maxSize]; //创建堆...
阅读全文
摘要:#include<iostream>#include<math.h>#define N 100000 //生成100000个质数using namespace std;int prime[N]; //一个全局数组,用来保存质数表void makeprime()//生成质数表的子函数{ int j,n=29,i=9,sqrtn;//从第10个质数开始计算,第10个质数是29 prime[0]=2; prime[1]=3; prime[2]=5; prime[3]=7; prime[4]=11; prime[5]=13; prime[6]=17; ...
阅读全文
摘要:#include<iostream>#include<string>usingnamespacestd;stringadd(conststring&a,conststring&b){stringresult;//用于记录计算结果intlen_a=a.length()-1;intlen_b=b.length()-1;intcarry=0;//进位for(;len_a>=0&&len_b>=0;len_a--,len_b--){intt=(a[len_a]-'0')+(b[len_b]-'0')+c
阅读全文
摘要:#include <cstdlib>#include <iostream>using namespace std;int Partition(int list[], int low, int high){ int pivotkey = list[low]; while(low < high) { while(low<high && list[high]>= pivotkey) high--; //找到第一个小于key的记录 if(low < high) list[low++] = list[high];//相当于交换了list[i
阅读全文
摘要:#include <stdio.h>#include <stdlib.h>static char Queen[8][8];static int a[8];static int b[15];static int c[15];static int iQueenNum = 0;//record statevoid qu(int i);int main(int argc, char *argv[]){ //init int line, column; for(line = 0;line < 8;line++) { a[line] = 0; for(colu...
阅读全文
摘要:使用异或a = a^b;b = a^b;a = a^b;异或运算法则 1. a ^ b = b ^ a 2. a ^ b ^ c = a ^ (b ^ c) = (a ^ b) ^ c; 3. d = a ^ b ^ c 可以推出 a = d ^ b ^ c. 4. a ^ b ^ a = b.
阅读全文
摘要:int max = ((a+b) + abs(a-b)) / 2;
阅读全文
摘要:// general versiontemplate<class T>class Compare{public:static bool IsEqual(const T& lh, const T& rh){return lh == rh;}}; 这是一个用于比较的类模板,里面可以有多种用于比较的函数, 以IsEqual为例。一、特化为绝对类型 也就是说直接为某个特定类型做特化,这是我们最常见的一种特化方式, 如特化为float, double等// specialize for floattemplate<>class Compare<float&g
阅读全文
摘要:CString str ;str = _T("1234"); int i = _ttoi(str);float f = _tstof(str);**************************数字转wchar_twchar_t c[10];int num = 100;_itow_s(num, c,10,10);wstring str(c);******************************wstring to int_wtoi(str.c_str());******************************如果你准备使用 Unicode 字符,你应该用_
阅读全文
摘要:1.static_cast用法:static_cast < type-id > ( expression )该运算符把expression转换为type-id类型,但没有运行时类型检查来保证转换的安全性。它主要有如下几种用法:①用于类层次结构中基类和子类之间指针或引用的转换。 进行上行转换(把子类的指针或引用转换成基类表示)是安全的; 进行下行转换(把基类指针或引用转换成子类表示)时,由于没有动态类型检查,所以是不安全的。②用于基本数据类型之间的转换,如把int转换成char,把int转换成enum。这种转换的安全性也要开发人员来保证。③把空指针转换成目标类型的空指针。④把任何类型
阅读全文
摘要:算术运算符+ -* /赋值运算符 = += -= *= \=&=赋值位与x&=0x02; |=赋值位或x|=0x02; 逻辑操作符 &&逻辑与if(x&&0xFF){...} ||逻辑或if(x||0xFF){...} 等式操作符 ==等于if(x==10){...} !=不等于if(x!=10){...} <小于if(x<10){...} >大于if(x>10){...} <=小于或等于if(x<=10){...} >=大于或等于if(x>=10){...} 一元操作符 *间接操作符intx=*y
阅读全文
摘要:[设置属性]首先用资源编辑器拖放一个ListCtrl控件到对话框中。设置属性。Always Show Selection: True // 即便失去焦点依然高亮选择SingleSelection: True // 只允许选中一行View: Report // 报表方式,较常用[初始化]// 在对话框的OnInitialDialog中初始化ListCtrl// 1. 设置样式m_ListCtrl.SetExtendedStyle( LVS_EX_FULLROWSELECT );// LVS_EX_FULLROWSELECT: 表示选中整行,而非某一列// LVS_EX_GRIDLINES: 显示
阅读全文
摘要:1 void FChartControl::CopyGridData() 2 3 { 4 5 if (m_bShowGrid) 6 7 { 8 9 CString csData = m_csHLable + _T("\n");10 11 int len=m_listCtrl.GetItemCount();//取行数12 13 14 15 for(int i=0;i<len;i++)16 17 {18 19 CString csRow;20 21 csRow = m_listCtrl.GetItemText(i,0)+_T("\t");22 23 c
阅读全文
摘要:Drop List 模式 没啥说的。 1 int num = m_cbTable.GetCount(); 2 3 FBusRouteTimeTable* pTable = (FBusRouteTimeTable*)itr->CurrentItem(); 4 5 m_cbTable.InsertString(num, pTable->GetName().c_str()); 6 7 m_cbTable.SetItemDataPtr(num, pTable); 8 9 10 11 m_cbTable.SetCurSel(0);12 13 主要说说Dropdown模式。因为是可编辑的,我想
阅读全文
1

浙公网安备 33010602011771号