#include "stdio.h"typedef struct{ char ch[40]; int len;}SString;void StrInsert(SString *s,int pos,SString *t){ int i; if(pos<0||pos>s->len) printf("pos is err\n"); if(s->len+t->len<=40) { for(i=s->len-1;i>=pos;i--) s->ch[i+t->len]= s->ch[i]; for(i=pos;i<t->len+pos;i++) s->ch[i]=t->ch[i-pos]; s->len=s->len+t->len; } else printf("insert is err\n");}void InitStr(SString *s){ int i=0; char k[40]; scanf("%s",k); for(i;k[i]!=0;i++) s->ch[i]=k[i]; s->len=i; }void main(){ void StrInsert(SString *s,int pos,SString *t); void InitStr(SString *s); SString *a,*t; InitStr(a); InitStr(t); StrInsert(a,2,t); printf("%s\n%d",a->ch,a->len);}
引用第8楼luwen于2007-12-02 16:43发表的 :不对