在 Linux 内核代码,特别是驱动代码中经常见到的用法是使用一个标准结构,后面的代码基于这个结构来实现,类似面向对象的多态特性。
在 C 语言里面借助结构体和函数指针实现的这个功能,这里我们写了个例子,提取了关键代码:
#include
struct s_new{
char name[10];
char* (* my_method)(char *name);...
分类:
系统相关 时间:
2014-05-23 07:58:18
阅读次数:
324
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
#include
#include
struct test
{
char name[20];
void (*func)(char *);
};
void tttfunc(char *name)
{
printf("current is %d\n",__LINE__);
printf("%s\n",name);
}
int main()
{
struct test ttt=
{
.n...
分类:
系统相关 时间:
2014-05-22 11:25:09
阅读次数:
380
//3、假定有20个 有序 数组,每个数组有500个数字,数字类型32位uint数值,现在需要取出这10000个数字中最大的500个,怎么做?
#include
using namespace std;
struct node
{
int data;
int next;
};
node obj[20];
void sift(int k,int m,int ...
分类:
其他好文 时间:
2014-05-22 10:54:48
阅读次数:
292
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
完全按照海涛哥剑指offer里边的递归思路来写的,基本一样,仅作学习验证,努力锻炼,努力学习!code如下:
//Change a BSTree to a sorted double linklist
struct BSTreeNode
{
int value;
BSTreeNode *left;
BSTreeNode *right;
}head;
//Create a node of...
分类:
其他好文 时间:
2014-05-22 10:23:27
阅读次数:
237
一。在Windows7 32bit ,IDE为VS2010中测试...
分类:
编程语言 时间:
2014-05-22 07:08:00
阅读次数:
469
DWORD WINAPI mythread( LPVOID lpParameter) //客户线程{ struct My my; memcpy(&my,lpParameter,sizeof(My)); printf("One client connect!\n"); char str1; ......
分类:
其他好文 时间:
2014-05-22 06:31:02
阅读次数:
319
#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