自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(29)
  • 收藏
  • 关注

原创 模拟卖票系统

#include #include #include #include #include int t = 100;pthread_mutex_t mutex;void *Sell(void* v){ int window = (int)v; printf("第%d个窗口开始卖票\n",window); while(1) { int time = rand(

2017-08-17 19:03:01 287

原创 字符串的“加密”

#include #include #include #define SIZE 1024void nixu(int* p){ int *p1 = p; int *p2 = p + sizeof(p)/sizeof(p[0]) - 1; while (p1 < p2) { int tmp = *p1; *(p1++) = *p2; *(p2--) =

2017-08-14 20:36:39 368

原创 标准I/O

fopen函数FILE *fopFILE *fopen(const char *path, const char *mode);fopen打开由path指定的文件,并把它与一个文件流关联起来。mode参数指定文件的打开方式。执行成功返回一个非空的FILE*指针,失败时返回NULL.其中mode参数的取值有:r,rb:只读方式打开;w,wb:以只写方式打开,并把文件长度截短为0;

2017-08-10 20:02:35 229

原创 进程控制

进程的生命周期:创建:每个进程都由其父进程创建。父进程可以创建子进程,子进程又可以创建子进程的子进程。运行:多个进程可以同时存在,进程之间可以进行通信。终止:结束一个进程的运行。获取id的函数  pid_t getpidpid_t getpid(void)  获取当前进程的idpid_t getppid(void)获取父进程的id进程创建函数fork

2017-08-09 19:25:48 199

原创 停车场(2)

#include "L.h"#include #include #define FALSE 0#define TRUE 1int count = 0;int a = 0;int main(){ Queue* Wait = Create_Queue(); Queue* Stop = Create_Queue(); LinkStack* Give = Cr

2017-08-07 10:03:14 263

原创 停车场(1)

#include "L.h"#include #include Queue* Create_Queue()//创建一个队列{ Queue * q = (Queue*)malloc(sizeof(Queue)/sizeof(char)); if (q == NULL) { return NULL; } // 置空队 q->front = NULL; q->rear

2017-08-07 09:58:58 306

原创 二叉树的实现

BTree *Create_BTree()//创建一个二叉树{ BTree *btree = (BTree*)malloc(sizeof(BTree)/sizeof(char)); if (btree == NULL) return NULL; btree->count = 0; btree->root = NULL; return btree;}int Bt

2017-08-07 09:53:57 188

原创 计算器(2)

#include "Calculator.h"#include #include #include #define FIRST 2;#define SECOND 3;#define THIRD 4;int sum;int main(){ Num *s; Ch *p; char str[100]; Num_Init (s); Ch_Init (p);

2017-08-07 09:32:39 190

原创 计算器(1)

#include "Calculator.h"#include "error.h"#include int Num_Init (Num *s){ if(s == NULL) { return FALSE; } s->top = -1; return TRUE;}int Ch_Init (Ch *s){ if(s == NULL) { return FAL

2017-08-07 09:30:27 332

原创 C语言树的建立

#include "SqQueue.h"int InitQueue (Queue *q)//建一个顺序队列并置空{ if (q == NULL) { return FALSE; } q->front = 0; q->rear = 0; return TRUE;}int QueueEmpty (Queue *q)//判断队列是否为空,为空返回真,否则返回假{

2017-08-07 09:24:27 6703 1

原创 顺序栈

#include "SqStack.h"int InitStack (Stack *S)//置空栈{ if (S == NULL) { errno = ERROR; return FALSE; } S->top = -1; }int StackEmpty (Stack *S)//判断栈是否为空,空返回真,不空返回假{ if (S == NULL) { errn

2017-08-07 09:14:11 273

原创 编一个C函数,子串在主串中出现多少次

#include #include int main(){ int a=0,b=0,count=0,j=0,i=0; char ch1[100],ch2[100]; printf("Please enter your string:"); gets(ch1); printf("Please enter your substring:"); gets(ch2); a=str

2017-08-06 20:22:37 658 1

原创 编程实现统计某年某月份的天数

#include int main(){ int a,b; char c; printf("Please enter the month to query, format such as: 2017.7.\n"); scanf("%d%c%d", &a, &c, &b); switch (b) { case 2 : if(a % 4 != 0 ||(a % 4 ==0

2017-08-06 20:18:51 571

原创 C语言系统编程

在Linux中,为了更好地保护内核空间,程序的运行空间分为内核空间和用户空间(也就是常称的内核态和用户态),它们分别运行在不同的级别上,在逻辑上是相互隔离的。因此,用户进程在通常情况下不允许访问内核数据,也无法使用内核函数,它们只能在用户空间操作用户数据,调用用户空间的函数。所有执行I/O操作的系统调用使用文件描述符来表示打开的文件。 文件描述符是一个非负整数。 文件描述符可以表示各种

2017-08-06 20:12:18 1201

原创 C语言递归李白打酒

void libai(int store, int flower,int alco, int pre, char *ch, int index) { if(store == 0 && flower == 0) { if(alco == 0 && pre == 0) { int i; for(i = 0;i < 15; i++) {

2017-08-06 20:10:42 930

原创 输入一个整数a,再输入两个整数p1,p2(p1,p2<32),输出该整数的二进制表示方法中从右端开始的p1到p2位.

#include void fun( int n, int p1, int p2){ int i; if(p1>p2) { int tmp; tmp=p2; p2=p1; p1=tmp; } for(i=p2;i>=p1;i--) { int tmp=0; tmp=(n>>(i-1))&1; if(tmp==1) { printf("1");

2017-08-06 20:09:13 1049

原创 编写一个c函数,该函数给出一个字节中被置为1的位的个数

#include int func(char ch){ int i; int n=0; for(i=0;i<8;i++) { if((ch>>i)&1==1) { n++; } } return n;}int main(){ char ch; scanf("%c",&ch); int n = func(ch); printf("%d\n",n);

2017-08-06 20:07:11 1058

原创 顺序队列

#include #include "SqQueue.h"int InitQueue (Queue *q)//创建队列{ if(q == NULL) { errno = ERROR; return FALSE; } q->front = 0; q->rear = 0;//初始队列没有元素}int QueueEmpty ( SeqQueue *q )//判断队列是否

2017-08-06 19:57:09 256

原创 链栈

#include #include "LinkStack.h"LinkStack *Creat_Stack ()//创建栈{ LinkStack *s = (LinkStack *)malloc(sizeof(LinkStack)/sizeof(char)); s->top=NULL; return s;}int StackEmpty (LinkStack *S)//判

2017-08-06 19:52:37 272

原创 几种基本的排序方法

#include void mg(int *a, int left, int mid, int right, int *tmp){ int i = left; int j = mid +1; int k = 0; while( i <= mid && j <= right) { if( a[i] < a[j] ) tmp[k++] = a[i++]; else

2017-08-06 19:33:57 232

原创 简易版通讯录

#include "LinkList.h"#include #include Node * Create_List()//建表{ Node *list = (Node*)malloc(sizeof(Node)/sizeof(char)); if (list == NULL) return NULL; list->next = NULL; // 空表 return li

2017-08-06 19:17:34 237

原创 C语言实现寻找合法帧

#include #include char *findStr(char*,char*);void findFrame(char*,char*,char*);//函数声明int main(){ char str[] = "asdheadhauboisoktailgdg"; findFrame(str,"head","tail"); return 0;}char *findStr

2017-07-20 20:04:55 841

原创 输入一个字符串,同时输入帧头和帧尾(可以是多个字符),将该字符串中合法的帧识别出来。

#include #include int main(){ char s[100]; char str1[100]; char str2[100]; printf("Please enter your string:\n"); gets(s); printf("Please enter the frame head:\n"); gets(str1); printf("P

2017-07-17 20:24:40 1829

原创 I am from shanghai 的倒序

#include #include int main(){ char str[100]; printf("Please enter the need to transform the statement:\n"); gets(str); char *p1 = str; char *p2 = str + strlen(str) - 1; char *p3; nixu(str

2017-07-16 21:46:14 277

原创 简单的计算器

#include int main(){ int a,b,res; char c; while(1) { printf("Please enter the calculation formula to calculate.\nIf you want to exit,please press CTRL + C.\n "); scanf("%d%c%d",&a,&c,&b);

2017-07-15 21:57:55 239

原创 有n个人围成一圈,顺序排号,从第一个开始报数(从1到3报数),凡报到3的人退出圈子,问最后最后留下的是原来第几号的那位

#include int main(){ int i,n,m=0,k=0,a[1000]; printf("请输入人数\n"); scanf("%d",&n); for(i=0;i<n;i++) { a[i]=i+1;//将每个人都放入数组之中 } while(m<n-1) { for(i=0;i<n;i++) { if(a[i]!=0)

2017-07-12 20:00:57 491

原创 选择排序

#include int main(){ int i,j,n,k,a[100]; printf("请输入要比较的数的个数\n"); scanf("%d",&n); printf("请输入要比较的数\n"); for(i=0;i<n;i++) { scanf("%d",&a[i]); } for(j=0;j<n;j++) { for(i=j;i<n;i++)

2017-07-11 17:57:14 141

原创 冒泡排序

#include int main(){    int i,j,n,k,a[100];printf("请输入要比较的数的个数\n");//缺点数组的长度scanf("%d",&n);printf("请输入要比较的数\n");for(i=0;i{scanf("%d",&a[i]);}for(j=0;j{for(i=0;i{if(a[i]>a

2017-07-11 17:49:30 186

原创 通过编程实现,统计1~n有多少个9

#include int main(){    int a,b,c,n,count=0;printf("请输入数字\n");scanf("%d",&n);for(b=1;b{c=b;while(c>8)//小于8的数没有9的产生{a=c%10;//把各个位数的数分开if(a==9)count++;c=c/10;}         }

2017-07-11 17:36:21 804

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除