Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
请教大牛Running&Judjing是什么意思?附有源码!!!!import java.util.*; public class Main_1002 { /** * @param args */ public static void main(String[] args) { // TODO Auto-generated method stub Tele tele=new Tele(); tele.inputTele(); tele.judge(); } } class Tele{ Scanner reader=new Scanner(System.in); int totalNum; String []teleNumber,solution,sol; public Tele() { totalNum=reader.nextInt()+1; teleNumber=new String[totalNum]; solution=new String[totalNum]; sol=new String[totalNum]; } void inputTele() { for(int i=0;i<totalNum;i++) teleNumber[i]=reader.nextLine().trim(); } void judge() { for(int i=0;i<totalNum;i++) { solution[i]=""; for(int j=0;j<teleNumber[i].length();j++) { char temp=teleNumber[i].charAt(j); switch(temp) { case '0': solution[i]+=0; break; case '1': solution[i]+=1; break; case 'A': case 'B': case 'C': case '2': solution[i]+=2; break; case 'D': case 'E': case 'F': case '3': solution[i]+=3; break; case 'G': case 'H': case 'I': case '4': solution[i]+=4; break; case 'J': case 'K': case 'L': case '5': solution[i]+=5; break; case 'M': case 'N': case 'O': case '6': solution[i]+=6; break; case 'P': case 'R': case 'S': case '7': solution[i]+=7; break; case 'T': case 'U': case 'V': case '8': solution[i]+=8; break; case 'W': case 'X': case 'Y': case '9': solution[i]+=9; break; default:break; } } } outputTele(); } void outputTele() { for(int i=0;i<totalNum;i++) { int k=0; sol[i]=""; try { for(int j=0;j<solution[i].length();j++) { if(k==3) { sol[i]=(sol[i]+'-').trim(); k++; } if(solution[i].charAt(j)!='-') { sol[i]=(sol[i]+solution[i].charAt(j)).trim(); k++; } } }catch(Exception e){} } String temp=""; for(int i=0;i<totalNum;i++) { for(int j=i+1;j<totalNum;j++) { if(sol[i].compareToIgnoreCase(sol[j])>0) { temp=sol[i]; sol[i]=sol[j]; sol[j]=temp; } } } int []time=new int[totalNum]; boolean fl=true; for(int i=0;i<totalNum;i++) { time[i]=1; for(int j=i+1;j<totalNum;j++) { if(sol[i].equalsIgnoreCase(sol[j])&&!sol[j].equalsIgnoreCase("*")) { time[i]++; sol[j]="*"; fl=false; } } } for(int i=0;i<totalNum;i++) { if(!sol[i].equalsIgnoreCase("*")&&time[i]>1) { System.out.print(sol[i]+" "); System.out.println(time[i]); } } if(fl) System.out.println("No duplicates."); } } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator