Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
哈哈哈哈啊In Reply To:大牛,救救小弟吧!!!!!RUNTIME ERROR!!!! Posted by:20080216 at 2010-06-02 12:52:53 > 请帮忙看一下代码!!跪谢!!!! > > > #include <stdio.h> > #include <string.h> > #include <stdlib.h> > > struct node > { > char str[20]; > char s[20]; > }; > > int cmp( const void *a, const void *b ) > { > return strcmp( (( struct node * ) a)->s , (( struct node * ) b)->s ); > } > > int bcmp( const void *a, const void *b ) > { > return strcmp( ( char * )a , (( struct node * ) b)->s ); > } > struct node t[10110]; > int main(void) > { > > char a[100], b[100]; > char str[100]; > int flag; > int u; > int i; > > int n; > > u = 0; > > while( gets( a ), a[0] != '\0' ) > { > i = 0; > n = strlen(a); > a[n] = '\0'; > > while( a[i] != ' ' ) > { > b[i] = a[i]; > i++; > } > b[i] = '\0'; > a[i] = '\0'; > i++; > while( a[i] == ' ' ) > { > i++; > } > > //strcpy( b, (a + i) ); > > > strcpy( t[u].str, b); > strcpy( t[u].s, a+i ); > u++; > } > > qsort( t, u, sizeof( struct node ), cmp ); > > while( scanf("%s", str ) != EOF ) > { > flag = 0; > > char *p; > > if( p = ( char * )bsearch( str, t, u, sizeof( struct node ), bcmp ), p != NULL ) > { > printf("%s\n", p ); > flag = 1; > } > > if( flag == 0 ) > printf("eh\n"); > i++; > } > > > return 0; > > } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator