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

wa 求测验数据 要是谁能帮我找出错来就更感谢了

Posted by cpp00548002 at 2006-03-21 20:05:18 on Problem 1002
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>
struct out
{
	int outc;
	int outn;
};
int fcmp(const void *a1,const void *a2)
{
	if((*(struct out *)a2).outc>(*(struct out *)a1).outc)
		return 0;
		else return 1;
}
void main()
{
	struct out outa[10000];
	char in[50],b[9];
	int n,m;
	scanf("%d",&n);
	int i,j,l,k;
	int g=0;
	for(i=0;i<n;i++)
	{
		m=0;
		scanf("%s",in);
		l=strlen(in);
		for(j=0;j<l;j++)
		{
			if(in[j]=='-') continue;
			if(in[j]<'Z'&&in[j]>='A')
			{
				if(in[j]>L'Q') in[j]--;
				m+=(in[j]-'A'+6)/3;
				m*=10;
				continue;
			}
			if(in[j]<='9'&&in[j]>='0')
			{
				m+=in[j]-'0';
				m*=10;
				continue;
			}
		}
		m/=10;
		for(j=0;j<g;j++)
		{
			if(m==outa[j].outc) 
			{
				outa[j].outn++;
				break;
			}
		}
		if(j==g) outa[g].outc=m,outa[g].outn=1,g++;
	}
	qsort(outa,g,sizeof(struct out),fcmp);
	k=0;
	for(i=0;i<g;i++)
		if(outa[i].outn>1)	
		{
			k++;
			for(j=0;j<4;j++)
			{
				b[7-j]='0'+outa[i].outc%10;
				outa[i].outc/=10;
			}
			b[3]='-';
			for(j=5;j<8;j++)
			{
				b[7-j]='0'+outa[i].outc%10;
				outa[i].outc/=10;
			}
			b[8]='\0';
			printf("%s %d\n",b,outa[i].outn);
		}
	if(k==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