通过在bbs提问,增加一个标志位,解决了线程ID不能重复,灰常感谢。 功能还是一样的,服务器接收消息然后打印,加了些服务器发送的确认消息。 注意
例:tcpdump host 172.16.29.40 and port 4600 -X -s 500 tcpdump采用命令行方式,它的命令格式为: tcpdump [ -adeflnNOpqStvx ] [ -c 数量 ] [ -F 文件名 ] [ -i 网络接口 ] [ -r 文件名] [ -s
最近今天在看socket编程,参考网上的例子,自己写了一个服务器回射程序,服务器端想用线程处理消息,但是线程这块还没想好怎么弄,现在只能规定
GTK+ and Glade3 GUI Programming Tutorial
http://www.micahcarrick.com/gtk-glade-tutorial-part-1.html
双向链表循环,完成插入删除搜素打印基本功能。 #include<stdio.h> #include<stdlib.h> typedef int elemType; typedef struct listnode{ elemType info; struct listnode * previous; struct listnode * next; }listnode; listnode * linkListInit(listnode * head){ head = NULL; return head; } listnode * addNode(listnode *head,elemType value){ listnode *ptr = (listnode *)malloc(sizeof(listnode)); ptr->info = value; if( NULL == head){ ptr->previous
#include<stdio.h> #include<stdlib.h> #include<string.h> char a[101],b[101]; int m[26],n[26]; void getNum(char *a,char *b){ int i,len1,len2; len1=strlen(a); len2=strlen(b); for(i=0;i<len1;i++) m[a[i]-'A']++; for(i=0;i<len2;i++) n[b[i]-'A']++; } int compare(const void *a, const void *b){ return ((*(int *)a)-(*(int *)b)); } void main(){ int i; int flag=0; memset(a,'\0',sizeof(a)); memset(b,'\0',sizeof(b)); gets(a); gets(b); getNum(a,b); qsort(m,26,sizeof(int),compare); qsort(n,26,sizeof(int),compare); for(i=0;i<26;i++){ if(m[i]!=n[i]){ flag=1; break; } } if(flag==1) printf("NO\n"); else printf("YES\n"); }
#include<stdio.h> #include<string.h> void main(){ int n; char s[53],c[26]; int i,l,count,leave; scanf("%d",&n); while(n != 0 && n<=20){ memset(s,'\0',sizeof(s)); memset(c,'0',sizeof(c)); scanf("%s",s); l=strlen(s); count=0; leave=0; for(i=0;i<l;i++){ if(count >= n){ if(c[s[i]-65] == '0'){ c[s[i]-65]='2'; leave++; continue; } else if(c[s[i]-65]=='2'){ continue; } } if(c[s[i]-65] == '0'){ c[s[i]-65] = '1'; count++; } else if(c[s[i]-65] == '1'){ c[s[i]-65] = '0'; count--; } } if(leave == 0) printf("All customers tanned successfully.\n"); else printf("%d customer(s) walked away.\n",leave); scanf("%d",&n); }
#include<stdio.h> #include<stdlib.h> #include<string.h> void main(){ int num,operation_num,max,capacity,curr,i,count=0,total; int device_Ampere[30]; char flag; char device_Flag[30]; scanf("%d %d %d",&num,&operation_num,&capacity); while(num != 0 && operation_num != 0 && capacity != 0){ flag='0'; max=0; total=0; for(i=1;i<=num;i++){ scanf("%d",&device_Ampere[i]); } memset(device_Flag,'0',sizeof(device_Flag)); for(i=0;i<operation_num;i++){ scanf("%d",&curr); if(device_Flag[curr] == '0'){ total+=device_Ampere[curr]; if(total>capacity) flag='1'; if(total>max) max=total; device_Flag[curr]='1'; } else{ total-=device_Ampere[curr]; device_Flag[curr]='0'; } } count++; printf("Sequence %d\n",count); if(flag=='1') printf("Fuse was blown.\n\n"); else{ printf("Fuse was not blown.\n"); printf("Maximal power consumption was %d amperes.\n\n",max); }
和队列一样简单实现push() pop() print()基本功能。 #include<stdio.h> #include<stdlib.h> typedef int elemType; typedef struct sNode{ elemType info; struct sNode *next; }sNode; typedef struct { int node; sNode * top; }LinkStack; void initStack(LinkStack *s){ s->node = 0; s->top = NULL; } void push(LinkStack *s, elemType value){ sNode *ptr = (sNode
C语言实现,只是简单实现了初始化、入队、出队和打印四个功能比较简单。 #include<stdio.h> #include<stdlib.h> typedef int elemType; typedef struct qNode{ elemType info; struct qNode *next; }qNode; typedef struct{ qNode *front; qNode *rear; }LinkQueue; void initQueue(LinkQueue *q){ // q->front = q->rear = (qNode *)malloc(sizeof(qNode)); // q->front->next = NULL; q->front