- 博客(29)
- 收藏
- 关注
原创 练习
#include #include #include struct menber{ int a; char *b;}temp={8,"zieckey"};void *create(void *arg){ printf("new thread ... \n"); return (void *)&temp;}i
2016-11-30 21:22:26 139
原创 练习
#include #include #include void *create(void *arg){ int *num; num=(int *)arg; printf("create parameter is %d \n",*num); return (void *)0;}int main(int argc ,cha
2016-11-29 21:23:18 143
原创 练习
#include #include #define BUFFER_SIZE 16struct prodcons{ int buffer[BUFFER_SIZE]; pthread_mutex_t lock; int readpos,writepos; pthread_cond_t notempty; pthread_
2016-11-28 22:51:10 134
原创 练习
共享内存:被多个进程共享一部分物理内存,共享内存是进程间共享数据的一种最快方法,一个进程向共享内存区内写入了多少数据,共享这个内存区域的所有进程就立刻可以看到其中的内容。1,创建 shmget函数 int shmget( key_t key,int size,int shmflg)该函数成功返回共享内存标识符,失败返回-12,shmat()将之前所创建的共享内存映射到当前内存
2016-11-27 22:05:00 156
原创 练习
#include #include #include #include //pipe函数#include int main(){ int fd_source[2];int fd_order[2];char r_buf[100];char w_buf[100];pid_t pid; int i;if(pipe(fd_source
2016-11-26 23:08:25 134
原创 练习
1、解释关键字:register (10分)请求编译器将变量存储在cpu内部寄存器中,直接访问而非通过内存访问。提高了运行效率,但不能定义太多变量,毕竟寄存器的空间有限。2、进程间通信有几种方式?请分别简述。 (20分)目前有6钟通信方式。1, 通过(有名)管道(pipe)和无名管道(FZFO)有名管道存于磁盘中,无名管道是特殊文件(设备文件)存在内
2016-11-25 22:37:03 149
原创 练习
#include void str_cpy(char* source,char* order){while(*order++=*source++);}int main(){char str_source[100];char str_order[100]; int i;printf("please enter a string:\n");
2016-11-24 22:36:40 150
原创 练习
/*有n个人围成一圈,顺序排号,从第一个开始报数(从1到3报数),凡报到的人退出圈子 ,问最后留下来的是原来第几号?(提示:使用数组)*/#include #include //malloc()#define call 3 //报道call的人退出int main(){ int n; printf(
2016-11-23 20:38:37 138
原创 链表 带表头 循环
#include #include struct node{int num;struct node * next;};typedef struct node Node;typedef struct node * Link;void create_newnode(Link *new_node);void create_link(
2016-11-22 22:23:01 160
原创 数据库版通讯录
#include #include #include int create_table(sqlite3 *db)//创建数据表{char *errmsg = NULL;char *sql;sql = "create table if not exists address_book (no integer primary key,name text,age int
2016-11-21 23:22:48 169
原创 函数与程序结构 例题
创建一个逆波兰表示法的计算器eg:(1-2)*(4+5)逆波兰表示法:12-45+*简单代码如下(只能完成基本的加减乘除,取模运算):#include #include //为了使用atof()函数#include #define MAXOP 100 //操作数或运算符的最大长度#define NUMBER '0'//标识找到一个数int getop(
2016-11-20 16:35:25 205
原创 练习
求输出下列杨辉三角形(要求输出10行)11 11 2 11 3 3 11 4 6 4 1.......//程序如下:#includeint main(){int i,j,a[10][10];for(i=0;ifor(j=0;ja[i][0]=1;a[i][i]=1; } for(i=2;i f
2016-11-19 20:49:11 118
原创 练习
#include int main(){int m=0,n,i,j,k,a=0;int row[10][10]; //定义一个10行10列的数组printf("please enter the number of rows:\n");printf("please enter the first number:");scanf("%d,%d",&m,&a);//输入行
2016-11-18 21:46:35 131
原创 练习
#include int main(){ int i,j,k;//i与j为循环变量,j比i小1,如果i可将j除尽,则将j视为其因数与k相加,若最终结果k的值等于i则找到完数printf("The complete is \n");for( i = 1; i {k = 0;for( j = 1; j {if( i%j == 0 ){k+=
2016-11-17 18:19:11 178
原创 练习
#include int main(){ int i,j,k;//i与j为循环变量,j比i小1,如果i可将j除尽,则将j视为其因数与k相加,若最终结果k的值等于i则找到完数printf("The complete is \n");for( i = 1; i {k = 0;for( j = 1; j {if( i%j == 0 ){k+=
2016-11-16 21:20:59 181
原创 文件练习
#include #include #include int main(){ FILE *text1;FILE *text2;FILE *text3;char ch1;char ch2;char ch3;int num1;int num2;int sum;//同时读取if((text1=fopen("text1.txt","
2016-11-15 22:32:06 129
原创 数据库练习
#include #include #include int create_table(sqlite3 *db){char *errmsg = NULL;char *sql;sql = "create table if not exists mytable(id integer primary key,name text);";if(SQLITE_OK !=
2016-11-14 23:49:33 154
原创 练习 系统调用
#include #include #include #define MAX 100int read_line(int fd, char *buf, int count){int i;char ch;for(i = 0; i { if((read(fd,&ch,1)) {perror("read error!\n
2016-11-13 22:23:31 302
原创 带表头结点的双向循环链表
#include #include /* ================= 定义链表数据结构 ================= */ struct node{ int num; struct node * next;struct node * prior;};typedef struct node Node;t
2016-11-12 23:19:05 600
原创 带表头结点的双向循环链表
#include #include /* ================= 定义链表数据结构 ================= */ struct node{ int num; struct node * next;struct node * prior;};typedef struct node Node;t
2016-11-11 21:34:06 528
原创 用链表实现栈
#include #include /*定义结构体,用户自定义*/struct node{int num;struct node * next;};typedef struct node Node;typedef struct node * Link;enum return_result{EMPTY_OK,EMPTY_NO,PUSH_OK,PUSH_
2016-11-10 23:10:07 153
原创 带表头结点的链表进行栈操作
#include #include /*定义结构体,用户自定义*/struct node{int num;struct node * next;};typedef struct node Node;typedef struct node * Link;enum return_result{EMPTY_OK,EMPTY_NO,PUSH_OK,PUSH_
2016-11-09 21:43:13 222
原创 栈练习
#include#include#define MAX 10struct stack_data{int stack[MAX];int top;};typedef struct stack_data Stack;enum return_result{FULL_OK,FULL_NO,EMPTY_OK,EMPTY_NO,PUSH_OK,PUSH
2016-11-07 22:11:33 180
原创 实现链表逆序(头插)
#include #include struct node{int num;struct node * next;};typedef struct node Node;typedef struct node * Link;void is_malloc_ok(Link new_node){ if(new_node == NU
2016-11-06 20:47:19 140
原创 有n个人围成一圈,顺序排号。从第一个人开始报数(1到3),凡报到3的人退出,问最后留下来的是几
include #define N 50 // 排队人数(可任意更改) #define CAL 3 //凡报3的人出列(可任意更改) //下面是排队编号函数:从h 开始的n个人依次编号1到n void stdline(int *h,int n) { int i; for(i=1;i } /*下面函数表示从
2016-11-05 22:00:16 979
原创 指针 练习
#include int main(){int average(float* p,int n);int search(float(*p)[4],int n);float score[3][4]={{65,67,70,60},{80,87,90,81},{90,99,100,98}};average(*score,12);search(score,2);
2016-11-04 22:58:44 164
原创 学习使用按位或 |
#includeint main(){ int a,b; a=077; b=a|3; printf("b 的值为 %d \n",b); b|=7; printf("b 的值为 %d \n",b); return0;}//输出结果b 的值为 63 b 的值为 63
2016-11-03 22:20:41 486
原创 字符串反转,如将字符串 ABC反转为 CBA
#include int reverse(char* s){ // 获取字符串长度 int len = 0; char* p = s; while (*p != 0) { len++; p++; } // 交换 ... int i = 0; char c; while
2016-11-02 22:09:10 710
原创 找⑨~~
#include int main(){//定义i为循环变量,计数器count(如果取模为9,则加1,相除为9,加1)int i = 0,count = 0;int tmp;int num;printf("Please input a final number:\n");scanf("%d",&num);//将从i到用户输入num
2016-11-01 22:09:56 148
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人