linux下实现多线程有两种函数调用:一种是通过pthread.h里面已经封装好的函数调用,另一种是通过unistd.h里面的fork函数调用。前面已经已经列举了pthread的使用,下面来书fork的例子。
一.fork函数
简单的fork例子
#include
#include
#include
using namespace std;
int main()
{...
分类:
编程语言 时间:
2014-05-23 07:59:41
阅读次数:
395
cocos2d-x升级到3.0后变化不小,除了API的变化(主要是函数和类名称变化,以及使用了C++11的不少特性,function/bind, lamda, std::thread…),创建和编译工程也做了一些简化调整。本文主要讨论一下cocos2d-x3.0 在android平台开发的环境设置及工程创建编译流程。...
分类:
移动开发 时间:
2014-05-22 13:38:47
阅读次数:
1044
以下四种情况,编译器将会合成(即由编译器负责)一个nontrivial默认构造函数。
1、成员对象带有默认构造函数
例如:
#include
using namespace std;
class Foo {
public:
Foo() { cout << "Foo" << endl; } // Foo类含有默认构造函数
};
class Bar {
pub...
分类:
其他好文 时间:
2014-05-22 13:24:06
阅读次数:
212
Interesting Calculator
CSU 过了 TOJ超时了 先记一下
#include
#include
#include
using namespace std;
int a[100];
bool b[100010];
int c[100010];
int d[100010];
int x, y;
int cas = 1;
struct node
{
int x, t,...
分类:
其他好文 时间:
2014-05-22 12:42:02
阅读次数:
249
#include
//#include
using namespace std;
struct node
{
char word[10];
int num;
};
node obj[100];
void my_word(char input[], char output[])
{
int sum=0,flag=0;...
分类:
其他好文 时间:
2014-05-22 12:41:25
阅读次数:
233
Sol:就是求第N项的斐波那契数。矩阵乘法+快速幂
#include
#include
#include
#include
using namespace std;
#define LL long long
struct Mat{
LL f[2][2];
};
LL MOD = 10000;
Mat mul(Mat a,Mat b)
{
LL i,j,k...
分类:
其他好文 时间:
2014-05-22 10:46:35
阅读次数:
191
题目:
链接:点击打开链接
题意:
给出N种设备的价值和数量,怎样尽可能的平分。
算法:
多重背包。
思路:
1.转化为01背包解决。2.使用单调队列优化O(VN)算法。
代码:
法一:
#include
#include
#include
using namespace std;
int n;
int v[55],m[55];
int...
分类:
其他好文 时间:
2014-05-22 09:09:38
阅读次数:
205
#include//中缀表达式求值
#include
using namespace std;
int precede(char t1,char t2) //shuru//判断优先级
{
int t=0;
switch(t2)
{
case '+':
case '-':
if(t1=='(...
分类:
其他好文 时间:
2014-05-22 07:48:44
阅读次数:
237
#include
using namespace std;
int func(int year)//判断闰年的个数
{
int count=0;
for(int i=1990;i
if(year%4==0&&year%100!=0||year%400==0)
count++;
return cou...
分类:
其他好文 时间:
2014-05-22 06:34:15
阅读次数:
252
#include
#include
using namespace std;
struct node
{
int shi;
int xu;
int data;
};
int main()
{
int shinum=0;
int xunum=0;
int n;
cin>>n;
node*num=ne...
分类:
其他好文 时间:
2014-05-20 15:28:05
阅读次数:
256