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

Re:哪位大侠帮忙看一下,TLE,到底是怎么回事.先谢谢了!!

Posted by catoran at 2006-07-17 21:34:08 on Problem 2418
In Reply To:哪位大侠帮忙看一下,TLE,到底是怎么回事.先谢谢了!! Posted by:catoran at 2006-07-17 21:33:26
> #include<stdio.h>
> #include<stdlib.h>
> #include<string.h>
> 	
> char  name[1000001][31];
> int sort_fun(const void *a,const void *b);
> 
> void main(){
> 
> 	char  sname[10000][31];	
> 	float	sname_fre[10000];
> 	int i=0,j=0,n=0,count=0;
> 	while((int)(gets(&name[i][0]))!=EOF){
> 		i++;
> 		n++;
> 	}
> 
> 	printf("n=%d\n",n);
> 
> 	qsort((void *)name,n+1,sizeof(name[0]),sort_fun);
>      
> 	count=1;
> 	for(i=0;i<n-1;i++){
> 		if(!strcmp(&name[i][0],&name[i+1][0])){
> 			if(i==n-1){
> 				strcpy(&sname[i][0],&name[i][0]);
> 				j++;
> 				strcpy(&sname[i+1][0],&name[i+1][0]);
> 				j++;
> 				sname_fre[i]=(float)(100*count)/n;
> 				count=1;
> 				sname_fre[i+1]=(float)(100*count)/n;
> 				count=1;
> 			}
> 			else{
> 				strcpy(&sname[i][0],&name[i][0]);
> 				j++;
> 				sname_fre[i]=(float)(100*count)/n;
> 				count=1;
> 			}
> 		}
> 		else
> 			count++;
> 	}
> 
> 	for(i=0;i<j;i++){
> 		printf("%s %0.4f\n",&sname[i],sname_fre[i]);
> 	}
> }
> 
> int sort_fun(const void *a,const void *b){
> 	return(strcmp((char*)a,(char*)b));
> }

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