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

用c过了gcc却wa不晓得咋整的/(ㄒoㄒ)/~~

Posted by Bug_Pu at 2015-03-21 16:55:43 on Problem 2418
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
typedef char State[33];
State st[1000010];
int cmp(const char* src, const char *_src){
	return strcmp((char *)src, (char *)_src);
}
int main(){
	State ret, buf;
	int i, k, cnt = 0;
	while (gets(ret)) strcpy(st[cnt++], ret);
	qsort(st, cnt, sizeof(st[0]), cmp);
	i = 0;
	while (i < cnt){
		strcpy(buf, st[i]), k = 0;
		for (; 0 == strcmp(buf, st[i]); i++) k++;
		printf("%s %.4lf\n", buf, (double)k * 100 / cnt);
	}
	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