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
以下四种情况,编译器将会合成(即由编译器负责)一个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
上周有厂商到公司测试,拿了一块据说很猛的网络处理加速PCIe板卡,拎在手里沉甸甸的很有分量,最让人意淫的是那4个万兆光口,于是我迫不及待的想要一览光口转发时那种看不见的震撼。 可是,仅凭4个光口怎么测试?起码你要有个“对端”啊!任何人应该都不想扛着三台机器在客户们之间跑来跑去测试其转发性能,当然你也不能指望客户那里就一定有你需要的“对端”设备,比如我们公司就没有这种和万兆光口对接的设备...
分类:
系统相关 时间:
2014-05-22 10:05:59
阅读次数:
351
题目:
链接:点击打开链接
题意:
给出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