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

我的有什么错呀求高手帮帮忙

Posted by xiaowei at 2006-05-14 11:17:20 on Problem 1002
#include<stdio.h>
#include<ctype.h>
#include<string.h>
compose(char a)
{
	if(a=='A'||a=='B'||a=='C')		return '2';
	if(a=='D'||a=='E'||a=='F')		return '3';
	if(a=='G'||a=='H'||a=='I')		return '4';
	if(a=='J'||a=='K'||a=='L')		return '5';
	if(a=='M'||a=='N'||a=='O')		return '6';
	if(a=='P'||a=='R'||a=='S')		return '7';
	if(a=='T'||a=='U'||a=='V')		return '8';
	if(a=='W'||a=='X'||a=='Y')		return '9';
}
main()
{
	char str1[100][20],result[100][20],str[20];
	int i,j,m,n,k,end[100];
	scanf("%d",&i);
	for(j=0;j<i;j++)
		scanf("%s",str1[j]);
	for(j=0;j<i;j++)
	{
		m=0;k=0;
		for(n=0;n<15;n++)
		{
			if(k==3){result[j][k]='-';k++;}
			if(isupper(str1[j][n])){result[j][k]=compose(str1[j][n]);k++;}
				if(isdigit(str1[j][n])){result[j][k]=str1[j][n];k++;}				
		}
		result[j][k]='\0';
	}
	for(m=1;m<i;m++)
		for(k=0;k<i-m;k++)
		{
			if(result[k][0]>result[k+1][0])
			{
				memcpy(str,result[k],10);
				memcpy(result[k],result[k+1],10);
				memcpy(result[k+1],str,10);
			}
		}
	for(j=0;j<i;j++)end[j]=1;
	for(j=0;j<=i;j++)
	{
		if(result[j][0]!='\0')
		{
		for(k=j+1;k<i;k++)
			if(strcmp(result[j],result[k])==0){end[j]++;result[k][0]='\0';}
		}
	}
	k=0;
	for(j=0;j<i;j++)
		if(end[j]>1&&(result[j][0]!='\0'))printf("%s %d\n",result[j],end[j]);
	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