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:没用排序,但是一直runtime Error,之前有人发帖说同样方法AC过,不知道原因

Posted by yinbenli at 2012-05-17 19:58:55 on Problem 1002
In Reply To:没用排序,但是一直runtime Error,之前有人发帖说同样方法AC过,不知道原因 Posted by:breezingtj at 2012-05-17 18:27:27
> #include <stdio.h>
> #include <stdlib.h>
> int main()
> {
> 	int data[10000000] = {0};
> 	int n;
> 	int i = 0,j = 0,k=0;
> 	char s[32];
> 	int m = 0;
> 	int p = 0;
> 	scanf("%d",&n);
> 	for(;i<n;i++) 
> 	{
> 		scanf("%s",s);	
> 		j = 0;
> 		k = 0;
> 		while(s[j] != '\0')
> 		{
> 			if(s[j] == '-')
> 			{
> 				j++;
> 				continue;
> 			}
> 
> 			if(s[j]>='A' && s[j] <= 'P')
> 			{
> 				//m = m * 10 + (s[j] - 'A') / 3 + 2;
> 				s[k] = (s[j] - 'A') / 3 + '2';
> 			}
> 			else if(s[j] > 'Q' && s[j] <= 'Y') 
> 			{
> 				//m = m * 10 + (s[j] - 'Q') / 3 + 7;
> 				s[k] = (s[j] - 'Q') / 3 + '7';
> 			}
> 			else 
> 				s[k] = s[j];
> 			j++;
> 			k++;
> 		}
> 		s[k] = '\0';
> 		m = atoi(s);
> 		data[m] ++; 
> 	}
> 
> 	i = 0;
> 	j = 0;
> 	for(;i<10000000;i++) 
> 	{
> 		if(data[i] > 1)
> 		{
> 			printf("%03d-%04d %d\n",i/10000,i%10000,data[i]);
> 			j = 1;
> 		}
> 	}
> 	if(j == 0)
> 		printf("No duplicates.\n");
> 	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