C' Fragment
°ÑÊäÈëµÄÒ»´®×Ö·ûת³ÉÊý×飬ת³ÉÁ´±í£¬È»ºóɾȥÆäÖÐÖ¸¶¨µÄ×Ö·û£¬ÔÚβ²¿Ìí¼ÓÒ»¸ö×Ö·û¡£
£¨³ÌÐò»¹²»ÍêÉÆ£¬Ã»ÓжÔÊä´íµÄÇé¿ö½øÐд¦Àí£¬£¬ÔÝʱÏÈÕâÑù°É¡£¡£= =¡££©
#include<stdio.h>
#include<malloc.h>
#define LEN sizeof(struct link)
struct link
{
char ch;
struct link *next;
}*string;
char a[80]={0};
void array()
{
scanf("%s",a);
}
void creat(char *a)
{
int i;
struct link *head,*p;
p=head=(struct link *)malloc(LEN);
for(i=0;i<80;i++)
{
if(*(a+i)!=0)
{
p->ch=*(a+i);
p->next=(struct link *)malloc(LEN);
p=p->next;
}
else
{
p->ch=0;
p->next=NULL;
break;
}
}
string=head;
}
void print(struct link *head)
{
struct link *p;
p=head;
while(p->next!=NULL)
{
printf("%c ",p->ch);
p=p->next;
}
printf("\n");
}
void del(struct link *head)
{
char a[1]={0};
struct link *p1,*p2;
p1=head;
printf("input the char you delete:");
scanf("%s",a);
while(a[0]!=p1->ch&&p1->next!=NULL)
{
p2=p1;
p1=p1->next;
}
if(p1==head)
head=p1->next;
else
p2->next=p1->next;
string=head;
print(head);
}
void add(struct link *head)
{
struct link *p;
char c[1];
printf("input the char you add:");
scanf("%s",c);
p=head;
while(p->next!=NULL)
p=p->next;
p->ch=c[0];
p->next=(struct link *)malloc(LEN);
p=p->next;
p->ch=0;
p->next=NULL;
print(head);
}
void main()
{
array();
creat(a);
print(string);
del(string);
add(string);
}
Ïà¹ØÎĵµ£º
ÒªÈà Eclipse ¿ÉÒÔ¿ª·¢ C/C++ ³Ìʽ£¬Òª¹ÒÉÏ CDT ²Å¿ÉÒÔ¡£
Ê×ÏÈÒªÏÂÔØCDT
CDTµÄ×îа汾ÊÇ 3.1.0£¬ËüÖ§³Öeclipse3.2.0£¬ÆäÏÂÔØµØÖ·£ºhttp://download3.eclipse.org/tools/cdt/releases/callisto/dist/3.1.0/£¬»òÕßÊǵ½http://www.eclipse.org/cdt/downloads.phpÏÂÔØÆäËü° ......
¹ØÓÚ#ºÍ##ÔÚCÓïÑԵĺêÖУ¬#µÄ¹¦ÄÜÊǽ«ÆäºóÃæµÄºê²ÎÊý½øÐÐ×Ö·û´®»¯²Ù×÷£¨Stringfication£©£¬¼òµ¥Ëµ¾ÍÊÇÔÚ¶ÔËüËùÒýÓõĺê±äÁ¿Í¨¹ýÌæ»»ºóÔÚÆä×óÓÒ¸÷¼ÓÉÏÒ»¸öË«ÒýºÅ¡£±ÈÈçÏÂÃæ´úÂëÖеĺ꣺
#define WARN_IF(EXP) \
do{ if (EXP) \
& ......
http://en.wikipedia.org/wiki/C_preprocessor
C preprocessor
from Wikipedia, the free encyclopedia
Jump to:navigation, search
The C preprocessor (cpp) is the preprocessor for the C programming language. In many C implementations, it is a separate program invoked by the compiler as the first part ......
#include<stdio.h>
#define N 8
void input(int n,int p[N][N])
{
int i,j;
for(i=0;i<n;i++)
{
printf("please input the %d line:\n",i+1);
for(j=0;j<n;j++)
{
scanf("%d",&p[i][j]);
}
}
}
void output(int n,int p[N][N])
......
Àý) Σ険¤Ê¥³ー¥Ç¥£¥ó¥°
1 char cStr[256];
2 ZeroMemory(cStr, sizeof(cStr));
3 &nb ......