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 langzhigang at 2012-03-03 17:22:23 on Problem 1002
In Reply To:给几个数据给大家。借鉴 Posted by:fbixiaozc135 at 2007-08-05 01:21:19
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
int d[100002]={0};
char a[100002][100];  //输入数组
char b[100002][100];  //输入后去除'-'的数组
int main()
{
	int i,j,k,n,min;
	char c[100];	
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%s",a[i]);
		for(k=0,j=0; ;j++)
		{		
			if(a[i][j]=='A' || a[i][j]=='B' || a[i][j]=='C')
			{
				a[i][j]='2';
			}
			if(a[i][j]=='D' || a[i][j]=='E' || a[i][j]=='F')
			{
				a[i][j]='3';
			}
			if(a[i][j]=='G' || a[i][j]=='H' || a[i][j]=='I')
			{
				a[i][j]='4';
			}
			if(a[i][j]=='J' || a[i][j]=='K' || a[i][j]=='L')
			{
				a[i][j]='5';
			}
			if(a[i][j]=='M' || a[i][j]=='N' || a[i][j]=='O')
			{
				a[i][j]='6';
			}
			if(a[i][j]=='P' || a[i][j]=='R' || a[i][j]=='S')
			{
				a[i][j]='7';
			}
			if(a[i][j]=='T' || a[i][j]=='U' || a[i][j]=='V')
			{
				a[i][j]='8';
			}
			if(a[i][j]=='W' || a[i][j]=='X' || a[i][j]=='Y')
			{
				a[i][j]='9';
			}
			if(a[i][j]!='-')
			{
				b[i][k]=a[i][j];
				k++;
			}
			if(a[i][j]=='\0')
			{
				break;
			}
		}
	} //n个字符串输入
	char e[100]={0};
	int t;
	for(i=0;i<n;i++)
	{
		for(j=i;j<n-1;j++)
		{
			if(strcmp(b[i],b[j+1])==0)
			{
				d[i]++;
				strcpy(b[j+1],e);
			}
		}
	}
	int x;
	for(x=0,i=0;i<n;i++)
	{	
		min=i;
		for(j=i;j<n-1;j++)
		{
			if(d[min]!=0 && d[j+1]!=0)
			{
				if(strcmp(b[min],b[j+1])>0)
				{
					min=j+1;	
				}
			}
		}

		strcpy(c,b[i]);
		strcpy(b[i],b[min]);
		strcpy(b[min],c);
		t=d[i];
		d[i]=d[min];
		d[min]=t;
		
		if(strcmp((b[i]),e)!=0 && d[i]!=0)
		{
			for(j=7;j>3;j--)
			{
				b[i][j]=b[i][j-1];
			}
			b[i][j]='-';
			printf("%s %d\n",b[i],d[i]+1);
			x++;
		}
		
	}
	if(x==0)
	{
		printf("No duplicates.");
	}
	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