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 |
ID2105 大家帮帮忙,我不知道为何老是Runtime Error [java]import java.io.*; import java.util.*; public class Main { public static void main (String args[]) throws Exception { BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); int ip[][]; String in_line; ip=new int[9][4]; in_line = in.readLine(); int n=Integer.parseInt(in_line); for(int i=0;i<n;i++) { in_line = in.readLine(); for(int j=0;j<3;j++) { ip[i][j]=toDec(in_line.substring(j*8,j*8+8)); } ip[i][3]=toDec(in_line.substring(24)); } for(int i=0;i<n;i++) { for(int j=0;j<3;j++) { System.out.print(ip[i][j]+"."); } System.out.println(ip[i][3]); } } public static int toDec(String s) { int r=0,n; int a[]={128,64,32,16,8,4,2,1}; for(int i=0;i<7;i++) { n=Integer.parseInt(s.substring(i,i+1)); r=r+(n*a[i]); } n=Integer.parseInt(s.substring(7)); r=r+n; return r; } } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator