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

1002

Posted by 2012082324 at 2013-04-13 13:55:50 on Problem 1002
实在不知道错哪里了;;;;;
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

char s[200001][100];
char ss[1000];
char s1[9];
int main()
{
	int n, i, j = 0, k, flag = 0;

	scanf("%d", &n);

	while (n--)
	{
		i = 0; k = 0;

		fflush(stdin);
		scanf("%s", ss);

		while (ss[i]!='\0')
		{
			switch (ss[i])
			{
			case '1': 
			case '0': 
					  break;
			case '2':
			case 'A':
			case 'B':
			case 'C': ss[i] = '2'; 
					  break;
			case '3':
			case 'D':
			case 'E':
			case 'F': ss[i] = '3'; 
					  break;
			case '4':
			case 'G':
			case 'H':
			case 'I': ss[i] = '4'; 
					  break;
			case '5':
			case 'J':
			case 'K':
			case 'L': ss[i] = '5'; 
					  break;
			case '6':
			case 'M':
			case 'N':
			case 'O': ss[i] = '6'; 
					  break;
			case '7':
			case 'P':
			case 'R':
			case 'S': ss[i] = '7'; 
					  break;
			case '8':
			case 'T':
			case 'U':
			case 'V': ss[i] = '8';
					  break;
			case '9':
			case 'W':
			case 'X':
			case 'Y': ss[i] = '9'; 
					  break;
			
			default : break;
			}

			if(ss[i]>='0'&&ss[i]<='9')
			{
				if(k==3)
				{
					s[j][k++] = '-';
				}
				s[j][k++] = ss[i];
			}
			i++;
		}
		j++;
	}
    for(i=0; i<j-1; i++)
	{
		for(k=i+1; k<j; k++)
		{
			if(strcmp(s[i],s[k])>0)
			{
				strcpy(s1, s[k]);
				strcpy(s[k], s[i]);
				strcpy(s[i], s1);
			}
		}
	}

	k = 1;

	for(i=0; i<j; i++)
	{
		if(strcmp(s[i],s[i+1])==0)
			k++;
		else
		{
			if(k>1)
			{
				flag = 1;
				printf("%s %d\n", s[i], k);
				k = 1;
			}
		}
	}
	if(flag==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