|
|
back to boardPlease help me This is My code.Time limit exid at the 10 test. Help me? import java.util.*; import java.io.*; public class Chat1 implements Runnable{ public static void main(String args[]){ new Thread(new Chat1()).start(); } BufferedReader in; PrintWriter out; ArrayList<String> ls; public void run(){ try{ in = new BufferedReader(new InputStreamReader(System.in)); ls=new ArrayList<String>(); out = new PrintWriter(new OutputStreamWriter(System.out)); solve(); out.flush(); }catch(IOException e){ throw new IllegalStateException(e);
} } void solve()throws IOException{ String s1="",s=""; char ch; int k=0,k3=0; boolean p=true;
while((k3=in.read())!=-1){
ch=(char)k3; if(p && ch!=' ' && ch!='.' && ch!='!' && ch!='?' && ((int)ch>=65 && (int)ch<=90)){ s+=ch; p=false;
} else{ if(ch=='!' || ch=='?' || ch=='.'){ p=true; s+=ch; } else{ if((int)ch>=65 && (int)ch<=90) s+=(char)((int)ch+32); else s+=ch; } }
} out.print(s);
} } |
|
|