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 Einest at 2013-03-25 22:57:09 on Problem 1002
#include<stdio.h>
int main(void)
{
	int a[100000],i,j,x,n,c[100000],ti,index,k;
	char b;
		scanf("%d",&n);
		for(j=1;j<=n;j++)
				a[j]=0;
		for(i=0;i<=n;i++){
			
            
			    
			while((b=getchar())!='\n'){
				ti=1;
				if((b>='0')&&(b<='9'))
					 x=b-'0';
				else if((b>='A')&&(b<='P'))
					x=(b-'A')/3+2;
				else if(b=='S'||b=='R')
					x=7;
				else if(b=='T'||b=='U'||b=='V')
					x=8;
                else if(b=='W'||b=='X'||b=='Y') 
				    x=9;
				else
					ti=0;
				if(ti==1)
				    a[i]=10*a[i]+x;
			}
		}
		
		
		for(i=1;i<n;i++){
			index=a[i];
			for(k=i;k<=n;k++){
				if(a[k]<index){
					index=a[k];
				    a[k]=a[i];
					a[i]=index;}
			}
		}

for(i=1;i<=n;i++)
			c[i]=1;
		
		for(i=1;i<=n;i++){
			k=a[i];
			for(j=i+1;j<=n;j++){
				if(a[j]==k){
					a[j]=-j;
					c[i]++;}
			}
		}
		
		
		
		
	
		for(i=1;i<=n;i++){
			if(c[i]>=2)
				printf("%03d-%04d %d\n",a[i]/10000,a[i]%10000,c[i]);
		}
		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