摘要: 问题描述:找出通过工厂装配线的最快方式 程序:#include //逆向输出路径void print_way(int l[][6],int l1){ cout0;i--){ coutf[1][5]+x[1]){ fmin=f[1][5]+x[1]; l1=2; } else { fmin=f[0][5]+x[0]; l1=1; } //输出f的值 cout<<"f[i][j]的值为"<<endl; for(int m=0;m<6;m++) { cout... 阅读全文
posted @ 2013-12-31 19:54 sxcww 阅读(255) 评论(0) 推荐(0) 编辑
摘要: 程序说明:线程a,b分别从字符串eg中取出一个字符,赋值给字符指针pro. 线程c,d分别从pro中取出字符,并打印程序用读写锁对线程abcd进行同步用到的读写锁函数有:#include int pthread_rwlock_rdlock(pthread_rwlock_t *rwptr); int pthread_rwlock_wrlock(pthread_rwlock_t *rwptr); int pthread_rwlock_unlock(pthread_rwlock_t *rwptr);#include #include #include#include#define RDNUM 2#. 阅读全文
posted @ 2013-12-29 20:17 sxcww 阅读(410) 评论(0) 推荐(0) 编辑
摘要: 1,内核中的某个消息队列可表示如下: 其中msqid_ds结构体为:struct msqid_ds { struct ipc_perm msg_perm; /* see Section 15.6.2 */ msgqnum_t msg_qnum; /* # of messages on queue */ msglen_t msg_qbytes; /* max # of bytes on queue */ pid_t msg_lspid; /* pid of last msgsn... 阅读全文
posted @ 2013-12-27 20:50 sxcww 阅读(276) 评论(0) 推荐(0) 编辑
摘要: 网络原题:编写一个程序,开启3个线程,这3个线程的ID分别为A、B、C,每个线程将自己的ID在屏幕上打印10遍,要求输出结果必须按ABC的顺序显示;如:ABCABC….依次递推这里设置ITEM=4,即依次打印ABCDABCD……………………#include #include #include/*int pthread_create(pthread_t*restrict tidp, * const pthread_attr_t *restrict_attr, * void*(*start_rtn)(void*),void *restrict arg);*//*第一个参数为指向线程标识符的指针。第 阅读全文
posted @ 2013-12-26 20:14 sxcww 阅读(1272) 评论(0) 推荐(0) 编辑
摘要: 1.消息队列也可以认为是消息链表,《unix网络编程卷二》中用下图表示了消息队列的可能分布。2.关于消息队列的函数如下所示:#include //创建,打开或删除IPC的函数mqd_t mq_open(const char *name,int flag,/*mode_t mode,struct mq_attr *attr */);int mq_close(const char *name);int mq_unlink(const char *name);//控制IPC操作的函数int mq_getattr(mqd_t mqdes,struct mq_attr *attr);int mq_set 阅读全文
posted @ 2013-12-25 16:01 sxcww 阅读(355) 评论(0) 推荐(0) 编辑
摘要: 参考:http://xwangly.iteye.com/blog/1109424Messenger介绍:Reference to a Handler, which others can use to send messages to it. This allows for the implementation of message-based communication across processes, by creating a Messenger pointing to a Handler in one process, and handing that Messenger to ano 阅读全文
posted @ 2013-10-24 16:43 sxcww 阅读(881) 评论(0) 推荐(0) 编辑
摘要: 1,定义:对于任何结点x,其左子树中的关键字最大不超过x->key,其右子树的关键字最小不小于x->key。如图所示: 为了简单起见,这里设结点包括key和eft,right,和p,分别为关键字、左结点、右结点、父结点。typedef struct node{ int key; struct node *left,*right,*p;//左结点,右结点,父结点}NODE;2,二叉树的初始化//数组a为初始化数据,len为数组长度NODE *init(int a[],int len){ if(len==0) return NULL; NODE *root;... 阅读全文
posted @ 2013-10-22 20:37 sxcww 阅读(198) 评论(0) 推荐(0) 编辑
摘要: 常见的函数调用方式有__cdecl、__stdcall、__fastcall(前面为双下划线)。1.__cdecl: 按从右至左的顺序压参数入栈,由调用者把参数弹出栈.int __cdecl func1(int a,int b,int c){ return a+b+c;}int main(){//函数调用 func1(1,2,3); return 0;}a.压栈顺序 //main.text:00401108 push 3 ; int.text:0040110A push 2 ... 阅读全文
posted @ 2013-10-20 21:32 sxcww 阅读(200) 评论(0) 推荐(0) 编辑
摘要: log信息如下:10-10 12:31:14.186: E/AndroidRuntime(22835): java.lang.IllegalStateException: The application's PagerAdapter changed the adapter's contents without calling PagerAdapter#notifyDataSetChanged! Expected adapter item count: 0, found: 4 Pager id: com.example.app:id/viewpager Pager class: 阅读全文
posted @ 2013-10-10 13:06 sxcww 阅读(10558) 评论(0) 推荐(0) 编辑