Learn English with English, baby!

Join for FREE!

Social_nav_masthead_logged_in

lauyachung de blog

View all entries from lauyachung de blog >

lauyachong

lauyachong

Colombia

November 2, 2008

#include<stdio.h> #include<string.h> #include<malloc.h> #define TRUE 1 #define FALSE 0 #define   Max 255 typedef struct {	char ch[255];	int len; } SeqString; int Strclear(SeqString *s) { 	s->len=0; 	return(TRUE); } int StrInsert (SeqString *s,int i,SeqString t) { 	int j; 	if(i<0||i>s->len) 	{ 		printf("插入位置不合理"); 		  return(FALSE); 		  } 	if(s->len+t.len<=Max) 	{ 		for(j=s->len+t.len;j>=t.len+i;j--) 			s->ch[j]=s->ch[j-t.len]; 		for(j=0;j<t.len;j++) 			s->ch[j+i]=t.ch[j]; 		s->len=s->len+t.len; 	} 	else if(i+t.len<=Max) 	{ 		for(j=Max-1;j>t.len+i+1;j--) 			s->ch[j]=s->ch[j-t.len]; 		for(j=0;j<t.len;j++) 			s->ch[j+i]=t.ch[j]; 		s->len=Max; 	} 	else 	{ 		for(j=0;j<Max-i;j++) 			s->ch[j+i]=t.ch[j]; 		s->len=Max; 	} 	return(TRUE); } int StrDelete(SeqString *s,int i,int j) { 	int k; 	if(i<0||i>(s->len-j)) 	{ 		printf("删除位置不合理"); 		return(FALSE); 	} 	for(k=i+j;k<s->len;k++) 		s->ch[k-j]=s->ch[k]; 	s->len=s->len-j; 	return(TRUE); } main() { 	SeqString *s1,s2; 	int i,j; 	s1=(SeqString*)malloc(sizeof(SeqString)); 	 	 	printf("输入顺序串s1:\n"); 	gets(s1->ch); 	s1->len=strlen(s1->ch); 	printf("输入顺序串s2:\n"); 	gets(s2.ch); 	s2.len=strlen(s2.ch); 	printf("输入插入位置"); 	scanf("%d",&i); 	StrInsert(s1,i,s2); 	printf("插入后的顺序串为:\n"); 	puts(s1->ch); 	printf("输入删除位置及栓出串的长度:"); 	scanf("%d,%d",&i,&j); 	StrDelete(s1,i,j); 	printf("删除后的顺序为:\n"); 	puts(s1->ch); }     

More entries: Indonesia dog killed Chinese Chinese in Indonesia (5), my ...my head is so ......... (1), bruce lee, so unhappy, do not want to stay in college (3), have no energy to write it in enlsih,i have written in my chinese Qzone.i just want to say ,chinese enducation systerm being is just a mistake.it is so dark!i hate it!, do not ask me how old are you.foreign friends,if you agree me ,please leave you comment , a chinese song(please do not leave me)have you heard ?, why should we recogenize?, learn chinese,can you leave your fellings to me?

View all entries from lauyachung de blog >

07:52 PM Nov 08 2008

Kahou

Kahou
Viet Nam

so....what?

I cannot see anything except a line of codes. >o<