Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

哈哈哈哈啊

Posted by 117474335 at 2010-09-19 23:16:36 on Problem 2503
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:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator