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

Help 1002, 487-8479!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

Posted by habits12 at 2006-09-04 20:40:30
#include<stdio.h>
#include<string.h>
#include<stdlib.h>

typedef struct
{
	int c;	
	int num;
}INFO;		

int _qsort(const void *a, const void *b)		
{
	return (*(INFO *)a).num - (*(INFO *)b).num;
}

INFO tnumb[100001];

void main(void)
{
	char str[100];		
	char tele[8];		
	int i;
	int n;				
	int j;
	int k;
	
	int intel;			
	int tn = 0;

	FILE *ifp = fopen("input.txt", "r");	
	
	scanf("%d", &n);
	fscanf(ifp, "%d", &n);

	for(i = 1; i <= n; i++)	
	{
		scanf("%s", str);		
		fscanf(ifp, "%s", str);
		k = 0;
		for(j = 0; j < 8; j++)
			tele[j] = -1;
		for(j = 0 ; j < strlen(str); j++)	
		{
			if(str[j] != '-')
			{
				switch(str[j])
				{
				case 'A': case 'B': case 'C': tele[k++] = '2';		break;
				case 'D': case 'E': case 'F': tele[k++] = '3';		break;
				case 'G': case 'H': case 'I': tele[k++] = '4';		break;
				case 'J': case 'K': case 'L': tele[k++] = '5';		break;
				case 'M': case 'N': case 'O': tele[k++] = '6';		break;
				case 'P': case 'R': case 'S': tele[k++] = '7';		break;
				case 'T': case 'U': case 'V': tele[k++] = '8';		break;
				case 'W': case 'X': case 'Y': tele[k++] = '9';		break;
				default:								tele[k++] = str[j];	break;
				}
			}
		}
		intel = atoi(tele);		
		for(j = 1; j <= tn; j++)
		{
			if(tnumb[j].num == intel)	
			{
				tnumb[j].c++;			
				break;
			}
		}
		if(j == tn+1)					
		{
			tnumb[++tn].num = intel;
			tnumb[tn].c++;
		}
	}
	
	qsort(tnumb+1, tn, sizeof(INFO), _qsort);	
	int chk = 0;
	for(i = 1; i <= tn; i++)	
	{
		if(tnumb[i].c > 1)
		{
			chk = 1;					
			printf("%d-%d %d\n", tnumb[i].num/10000, tnumb[i].num%10000, tnumb[i].c);
		}
	}
	
	if(chk == 0)					
		printf("No duplicates.\n");
}

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