Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

Á´±íµÄ»ù±¾²Ù×÷(cʵÏÖ£©

  
Á´±í¶¨Òå¼°²Ù×÷µÄÔ´Îļþ£ºemployee.h
//
#pragma once
#ifndef __EMPLOYEE_H__
#define __EMPLOYEE_H__
#include<stdio.h>
#include<malloc.h>
typedef struct employee{
int id;
int age;
int salary;
}EmpType;
typedef struct Node{
EmpType data;
struct Node *next;
}LNode,*PNode ,*LinkList;
typedef LinkList EmpLinkList;
//³õʼ»¯Á´±í
int InitEmpLinkList(LinkList *h)
{
*h=(LinkList)malloc(sizeof(LNode));
if (!h) {printf("init failed!\n");return 0;}
(*h)->next=NULL;
return 1;
}
//ÏòÁ´±íÖÐposÖеÄλÖòåÈëÊý¾Ýdata
int InsertEmpLinkList(LinkList h,int pos,EmpType data)
{
int i=0;
PNode p=h,q;
while (p&&i<pos-1)
{
p=p->next;
i++;
}
if (!p||i>pos-1) {printf("the insert position is illegal!\n");return 0;}
q=(PNode)malloc(sizeof(LNode));
if (!q) {printf("can not create new node !\n");return 0;}
q->data=data;
q->next=p->next;
p->next=q;
return 1;
}
//´òÓ¡Á´±íÖÐageΪijֵµÄ½áµã
int PrintByAge(LinkList h,int age,PNode *pnode)
{
PNode p=h->next;
while (p&&p->data.age!=age)
p=p->next;
if (!p) {printf("can not find the age!\n");return 0;}
(*pnode)=p;
printf("%d,%d,%d",(*pnode)->data.id,(*pnode)->data.age,(*pnode)->data.salary);
printf("\n");
return 1;
}
//·µ»ØijidµÄ½áµã
PNode FindNodeById(LinkList h,int id)
{
PNode p=h->next;
while (p&&p->data.id!=id)
p=p->next;
return p;
}
//·µ»ØijidµÄλÖÃ
int GetPos(LinkList h,int id)
{
PNode p=h->next;
int i=0;
while (p&&p->data.id!=id)
{
p=p->next;
i++;
}
if (!p)
return 0;
return i;
}
//±éÀúÁ´±í
void TraverLinkList(LinkList h)
{
PNode p=h->next;
while (p)
{
printf("%d,%d,%d",p->data.id,p->data.age,p->data.salary);
printf("\n");
p=p->next;
}
}
#endif
Ö÷º¯Êý£¨²âÊÔ£©main.c
#include"employee.h"
int main(int argv,char * argc[])
{
EmpLinkList l; //¶¨ÒåÁ´±í
EmpType data; //¶¨ÒåÁ´


Ïà¹ØÎĵµ£º

¹ØÓÚC/C++ÖÐÖ¸Õë×öÐβεÄÒ»µãС·ÖÎö(ת)

 
2009-07-26 15:50
½ñÌìÇÞÊÒµÄɽ¶«ÐÖµÜÔÚÁ·¶þ¼¶µÄÉÏ»ú£¬ÆäÖÐÒ»¸öÌâÄ¿´ó¸ÅÊÇÕâÑù£ºÔÚÒ»¸öº¯ÊýÖУ¬ÓÐÒ»¸öÖ¸ÕëÐβΣ¬¼ÇΪ*p£¬È»ºóÔÚº¯ÊýÄÚ²¿¶¨ÒåÁËÁÙʱ±äÁ¿a,aºÍ*pÊÇͬÖÖÀàÐÍ¡£¾­¹ýһϵÁмÆËã £¬aµÃµ½ÁËÒ»¸öÖµ£¬Õâ¸öÖµ×îºóÊÇÐèÒª¼Ç¼ÔÚÖ¸Õë*pÀïÃæµÄ£¬Ó¦¸ÃÔõô±£´æÄØ£¿ÎÒµ±Ê±Ëæ±ã¾Í˵£¬p=&a¡£½á¹û·¢Éú´íÎóÁË£¬Ã»Óе ......

CºêµÄÓ÷¨

Ç°¼¸Ìì²Î¼Óij¹«Ë¾µÄ±ÊÊÔ£¬ÓÐÒ»µÀÌâÊÇÓô¿CʵÏÖÒ»¸ö·ºÐͺ¯Êý¡£ÓôÃÆÁ˺þÃÓÃC++Ä£°åʵÏÖÁË¡£
ºêÓÐÈçϵÄÌص㣺
1.ÓëconstÏà±È£¬ºêÊÇÔÚÔ¤±àÒëµÄʱºòÍê³ÉµÄ
2.define Ö»×ö¼òµ¥µÄÌæ»»£¬²»×öÀàÐÍ°²È«¼ì²é
3.ʹÓò»µ±»áÒýÆðºÜ¶àÎÊÌâ
ºêµÄÓ÷¨£º
1.¼òµ¥µÄºê¶¨Òå
#define  MAX 1024
2.ºê¶¨Ò幦ÄÜ¿é
#define MAX(a,b) ( ......

c socket ·¢ËÍhttpÇëÇó

#include <sys/types.h>
#include <sys/socket.h>
#include <sys/types.h>
#include <stdio.h>
#include <netinet/in.h>
#include <arpa/inet.h>
int main(){
int sockfd;
int len;
struct sockaddr_in address;
int result;
char *strings="GET /svnup/rewrite.php HTTP/1 ......

CÖкê#ºÍ##µÄÔËÓÃ

 #include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <malloc.h>
#define f(a,b) a##b
#define g(a)  #a
#define h(a) g(a)
int main()   
{   
    char a = 'a';      
    ......

´ÓÁ½µÀ¾­µäÊÔÌâ̸C/C++ÖÐÁªºÏÌ壨union£©µÄʹÓÃ


´ÓÁ½µÀ¾­µäÊÔÌâ̸C/C++ÖÐÁªºÏÌ壨union£©µÄʹÓÃ
ÊÔÌâÒ»£º±àдһ¶Î³ÌÐòÅжÏϵͳÖеÄCPUÊÇLittle endian»¹ÊÇBig endianģʽ£¿
·ÖÎö£º
×÷Ϊһ¸ö¼ÆËã»úÏà¹ØרҵµÄÈË£¬ÎÒÃÇÓ¦¸ÃÔÚ¼ÆËã»ú×é³ÉÖж¼Ñ§Ï°¹ýʲô½ÐLittle endianºÍBig endian¡£Little endianºÍBig endianÊÇCPU´æ·ÅÊý¾ÝµÄÁ½ÖÖ²»Í¬Ë³Ðò¡£¶ÔÓÚÕûÐÍ¡¢³¤ÕûÐ͵ÈÊý¾ÝÀàÐÍ£ ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ