- 博客(15)
- 资源 (2)
- 收藏
- 关注
原创 在TS语言H5项目中使用Protobufjs(二) - Layaair腊鸭引擎篇
大家好,又见面了,上一篇我们介绍了如何在Egret中使用Protobufjs。至于为什么选protobufjs,请点击这里阅读我上一篇文章这篇我们重点介绍,如何在Layaair的TS项目中使用它。首先,因为我用的是ts版本创建的项目。所以能和Egret一样使用。只是配置有所区别。 如何安装 npm install protobufjs@6.8.4 -g ...
2018-10-08 11:36:30 1355
原创 调用拷贝构造函数的三种形式
#include #include using namespace std;class MyClass{public: MyClass(int x1 = 1, int y1 = 2); MyClass(const MyClass& mc1); void print() { cout<<x<<'\t'<<y<<endl; }private: int x,y;};M
2014-03-19 09:27:38 701
原创 输出迭代器 ostream_iterator 把输入的一串字符按每行一个单词输出
//split头文件#include #include #include #include #include using namespace std;inline bool space(char c){ return isspace(c);}inline bool not_space(char c){ return !isspace(c);}template
2014-03-18 16:36:11 519
原创 统计各单词出现的行数---键值对
#include #include #include #include #include //使用关联式容器map musing namespace std;vector split(const string&);//把各行的单词放进键值对中,即单词和单词出现的行数,行数保存在一个向量中map > xref(istream& in, vector find_words(co
2014-03-14 17:17:55 492
原创 利用键值对统计单词出现的次数
#include #include #include #include //使用关联式容器map musing namespace std;void main(){ string s; map counters; while (cin>>s) { ++counters[s]; //增加每个单词出现的次数 } for (map::const_iterator i
2014-03-14 15:48:07 490
原创 辗转相除法求两个数是否互素
#include using namespace std;int gcd(int x,int y);void main(){ int x,y; cin>>x>>y; if(gcd(x,y)==1) cout<<"互素!"<<endl; else cout<<"不互素!"<<endl;}//版本一int gcd(int x,int y){ int c;
2014-03-07 11:11:20 2972
原创 在一个矩形框中输出一条问候语
第一个版本// ask for a person's name, and generate a framed greeting#include #include int main(){ std::cout << "Please enter your first name: "; std::string name; std::cin >> name; // build the
2014-03-05 09:36:00 594
原创 求两个数的最大公约数和最小公倍数
#includeint qzdgys(int m,int n) /*求最大公约数*/{ int min; if(m<=0||n<=0) return -1; if(m>n) /*取输入的两个数中最小的数赋给min*/ min=n; else min=m; while(min) { if(m%min==0 && n%min==0) /*分别对mi
2014-02-24 20:46:12 583
原创 把一个合数分解为几个质因数相乘
#include int a(int a){ int i; for(i=2; i<a; ++i) if(a%i == 0) return 0; //a为合数时返回0 return 1; //a为质数时返回1}//递归函数void f(int n){ if(a(n)) printf("n=%d是一个质数!\n",n); else { printf("%d=
2014-02-24 20:04:17 2373
原创 求f(x)=1-x的2次方的定积分
//求f(x)=1-x2的定积分#include #include #include #include double p(int n){double x,y;time_t t;int i,count=0;srand((unsigned)time(&t));for(i=0;i<n;i++){x=rand()%100/100.0;y=rand()%100/100.0;if(y<=1-pow(x,2))
2014-02-24 19:55:29 2928
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人