| ||||||||||
| 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 | |||||||||
给个java的高效读取程序,此题读取量大,多次读取可能tle class Reader{
byte[] b;
int i;
Reader(int length){
b = new byte[length];
i = 0;
}//此题length可设为1100000
public int lineLength(){
while(b[i]!=13&&b[i]!=10)i++;
return i;
}
private void skip(){
while(b[i]==13||b[i]==10||b[i]==32)i++;
}
public int nextInt(){
skip();
String s=new String();
while(b[i]>47&&b[i]<58)s+=(char)b[i++];
return Integer.parseInt(s);
}
public char nextChar(){
skip();
return (char)b[i++];
}
}
Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator