汝欠咱的一生
字符串存

现在用 字符串存,然后读取指定下标。 服务器判WA。求解。

[mw_shl_code=c,true]#include<stdio.h>

#include<malloc.h>

#include<string.h>

#define max 1001

typedef struct Node

{

int data;

char en[max];

char cn[max*10];

struct Node *next;

}LNode,*List;

int List_add(List L,char *a)

{

int ok=0;

while(L->next!=NULL)

{

L=L->next;

if(strcmp(L->en,a)==0)

{

ok=1;

break;

}

}

if(ok==1)

{

char str[10];

scanf("%s",str);

strcat(L->cn,str);

}

else

{

List New=(LNode*)malloc(sizeof(LNode));

strcpy(New->en,a);scanf("%s",New->cn);

New->next=L->next;

L->next=New;

}

}

int List_show(List L,char *a)

{

int i=0,n;

char str[10];

scanf("%d",&n);

while(L->next!=NULL)

{

L=L->next;

if(strcmp(L->en,a)==0)

{

i=1;

int len=strlen(L->cn);

if(n>len/2)

str[0]=L->cn[len-2],str[1]=L->cn[len-1],str[2]='\0';

else

str[0]=L->cn[2*n-2],str[1]=L->cn[2*n-1],str[2]='\0';

printf("%s\n",str);return 0;

}

}

if(i==0)printf("NO\n");

}

int main()

{

List L=(LNode*)malloc(sizeof(LNode));

L->next=NULL;

char a[max];

while(scanf("%s",a)!=EOF)

{

if(strcmp(a,"end")==0)break;

List_add(L,a);

}

while(scanf("%s",a)!=EOF)

{

if(strcmp(a,"end")==0)break;

List_show(L,a);

}

return 0;

}

[/mw_shl_code]