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 jcy2000 at 2019-08-03 13:58:32 on Problem 1002
#include<stdio.h>
#include<string.h>
int main()
{
	void swop(char *p,char *q);
	char a[16],b[100000][10];
	char *p,*q;
	char c[25]={"ABCDEFGHIJKLMNOPRSTUVWXY"};
	int i,j,n,k,m;
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%s",a);
		k=0;
		for(j=0;j<16;j++)
		{
			if(k==3)
			{
				b[i][k]='-';
				k=k+1;
				j=j-1;
				continue;
			}
			else
			{
				if('0'<=a[j]&&a[j]<='9')
				{
					b[i][k]=a[j];
					k=k+1;
					continue;
				}
				if('A'<=a[j]&&a[j]<='Y'&&a[j]!='Q')
				{
						
						if(a[j]<81)
						{
							m=a[j]-65;
							m=m/3;
						}
						else
						{
							m=a[j]-66;
							m=m/3;
						}
						switch(m)
						{
						case 0:b[i][k]='2';k=k+1;break;
						case 1:b[i][k]='3';k=k+1;break;
						case 2:b[i][k]='4';k=k+1;break;
						case 3:b[i][k]='5';k=k+1;break;
						case 4:b[i][k]='6';k=k+1;break;
						case 5:b[i][k]='7';k=k+1;break;
						case 6:b[i][k]='8';k=k+1;break;
						case 7:b[i][k]='9';k=k+1;break;
						}
						continue;
				}
				if(a[j]=='-')
					continue;
				if(a[j]=='\0')
				{
					b[i][k]='\0';
					break;
				}
			}
		}
	}
	m=n-1;
	for(j=0;j<n-1;j++,m--)
	for(i=0;i<m;i++)
	{
		if(strcmp(b[i],b[i+1])>0)
		{
			p=&b[i][0];
			q=&b[i+1][0];
			swop(p,q);
			continue;
		}
		else
			continue;
	}
	i=0;
	m=1;
	for(i;i<n;i++)
	{
		if(strcmp(b[i],b[i+1])==0)
		{
			m=m+1;
			continue;
		}
		else
		{
			if(m>1)
			printf("%s %d\n",b[i],m);
			m=1;
			continue;
		}
	}
	return 0;
	}
void swop(char *p,char *q)
{
	char m;
	int i;
	for(i=0;i<8;i++)
	{
		m=*(p+i);
		*(p+i)=*(q+i);
		*(q+i)=m;
	}
}

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